ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1020. Rope

Why Time Limit?
Posted by Ursul Alex 29 Jun 2009 08:10
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;
}