|
|
back to boardDiscussion of Problem 1020. RopeMy code gets WA, any help appreciated Posted by Daniel 2 Aug 2002 21:07 #include <stdio.h> #include <math.h> int main() { float ans,r,x[100], y[100]; int n,i; scanf("%d %f", &n, &r); for (i = 0; i < n; i++) scanf("%f %f", &x[i], &y [i]); ans = 2*r*3.14159; if (n > 1) { for (i = 0; i < n-1; i++) ans += sqrt( (x[i]-x[i+1])*(x[i]-x[i+1]) + (y[i]-y[i+1]) * (y [i]-y[i+1])); ans += sqrt( (x[n]-x[1])*(x[n]-x[1]) + (y[n]-y[1]) * (y[n]-y [1])); } printf("%.2f\n", ans); return 0; } |
|
|