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 wa 4?
Posted by Dejust 21 May 2011 17:56
What's wrong?

#include <iostream>
#include <math.h>
#include <stdio.h>
int _1020()
{
    double r = 0.0; // Радиус шляпок
    int n = 0; // Число гвоздей

    std::cin >> n >> r;
    double f_x = 0.0;
    double f_y = 0.0;
    std::cin >> f_x >> f_y;
    --n;    // Первая строка уже введена

    double length = 0.0;
    double t_x = 0.0;
    double t_y = 0.0;

    double c_x = 0.0;
    double c_y = 0.0;

    for(int i = 0; i < n; i++)
    {
        std::cin >> c_x >> c_y;
        if(i == n-1)
        {
             length += sqrt(pow(f_x - c_x, 2) + pow(f_y - c_y, 2));
        }

        length += sqrt(pow(c_x - t_x, 2) + pow(c_y - t_y, 2));

        t_x = c_x;
        t_y = c_y;
    }
    length += 2*acos(-1.0)*r;

    std::cout.setf(std::ios_base::fixed,std::ios_base::floatfield);
    std::cout.precision(2);
    std::cout << length << "\n";

    return 0;
}
Re: why wa 4?
Posted by AterLux 21 May 2011 21:26
first coordinates differ from 0.0 in that test
Re: why wa 4?
Posted by Dejust 22 May 2011 13:36
Thank u! I got AC

Error was very stupid.. (wrong condition in for(){}) :)