|
|
back to boardDiscussion of Problem 1020. RopeWrong Answer on test #4, C Posted by Regret 25 Nov 2017 21:27 #include <stdio.h> #include <math.h> #define M_PI 3.14159 int main() { int N; float R, result = 0; scanf("%d", &N); scanf("%f", &R); if (N == 1) { result = 2 * R * M_PI; } else { float nails[N][2];
for (int i = 0; i < N; i++) { for (int j = 0; j < 2; j++) { scanf("%f", &nails[i][j]); } }
for (int i = 1; i <= N; i++) { result += sqrt((nails[i][0] - nails[i - 1][0]) * (nails[i][0] - nails[i - 1][0]) + (nails[i][1] - nails[i - 1][1]) * (nails[i][1] - nails[i - 1][1])); }
result += (M_PI * 2 * R);
} printf("%.2f", result); return 0; } Re: Wrong Answer on test #4, C Edited by author 11.09.2018 16:32 |
|
|