|
|
back to boardDiscussion of Problem 1020. RopeWhy Time Limit? Hello, guys. Can you tell me, why i got TL for this? #define _USE_MATH_DEFINES #include <stdio.h> #include <math.h> struct Point { float x; float y; }; int main() { freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); int nPins = 0; float pinRadius = 0; scanf("%d %f\n", &nPins, &pinRadius); Point points[101]; for (int i = 0; i < nPins; i++) { scanf("%f %f\n", &points[i].x, &points[i].y); } float len = 2*M_PI*pinRadius; for (int i = 1; i < nPins; i++) { len += sqrt(pow(points[i].x - points[i-1].x, 2) + pow(points[i].y - points[i-1].y, 2)); } len += sqrt(pow(points[0].x - points[nPins-1].x, 2) + pow(points[0].y - points[nPins-1].y, 2)); printf("%.2f\n", len); return 0; } |
|
|