Advertisement
nontawat1996

1054

Sep 28th, 2011
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. int main()
  5. {
  6.     int n,i,j,total=0,difx,dify,sumr;
  7.     int *x,*y,*r;
  8.     scanf("%d",&n);
  9.     x=(int *)malloc(sizeof(int)*n);
  10.     y=(int *)malloc(sizeof(int)*n);
  11.     r=(int *)malloc(sizeof(int)*n);
  12.  
  13.     for(i=0; i<n; i++) scanf("%d %d %d",&x[i],&y[i],&r[i]);
  14.  
  15.     for(i=0; i<n; i++)
  16.     {
  17.         for(j=i+1; j<n; j++)
  18.         {
  19.  
  20.             difx=x[i]-x[j];
  21.             dify=y[i]-y[j];
  22.             sumr=r[i]+r[j];
  23.  
  24.             if(pow(sumr,2)>pow(difx,2)+pow(dify,2)) total++;
  25.  
  26.         }
  27.  
  28.  
  29.     }
  30.     printf("%d",total);
  31.     return 0;
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement