|  | 
|  | 
| back to board | Discussion of Problem 1020. RopeShit , Whats wrong with my code ??? /** URAL v1 1020
 * ID : ******
 * 2003 - 05 - 22
 */
 
 #include<stdio.h>
 #include<math.h>
 
 #define Pi 3.14
 
 typedef struct Nail Nail;
 struct Nail
 {
 double x;
 double y;
 };
 
 double cal(int x,int y)
 {
 return sqrt(x*x+y*y);
 }
 
 int main()
 {
 int N;
 double R,length = 0,curve;
 int i;
 Nail nail[100];
 
 /* read data */
 scanf("%d %lf",&N,&R);
 for(i = 0;i < N;i++)
 scanf("%lf %lf",&nail[i].x,&nail[i].y);
 
 curve = 2*Pi*R;
 /* calculate */
 for(i = 0;i < N;i++)
 if(i == N-1)
 length += cal(nail[i].x - nail[0].x,nail[i].y - nail[0].y);
 else
 length += cal(nail[i].x-nail[i+1].x,nail[i].y-nail[i+1].y);
 
 /*  output */
 printf("%.2f",length+curve);
 
 return 0;
 }
my email is : do_o3@hotmail.com | 
 | 
|