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

What is wrong? / WA#1
Posted by Segrey_Shustov_rus 4 Jun 2017 12:52
#include <iostream>
#include <iomanip>
#include <cmath>
using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
int main()
{
    int n;
    double r,s=0,x,y,x0,y0,xn,yn;
    cin >> n >> r;
    if (n==1) {
        cin >> x >> y;
    }
    if (n>1) {

            cin >> x >> y;
    for (int i=1;i<=n-1;i++) {
    cin >> x0 >> y0;
    s=s+sqrt((x0-x)*(x0-x)+(y0-y)*(y0-y));
    x=x0;y=y0;
    }
    s=s+sqrt((xn-x)*(xn-x)+(yn-y)*(yn-y));
            }
s=s+2*3.1415*r;
cout << fixed << setprecision(2) << s << endl;

    return 0;
}

DEV-C++ 5.11

Edited by author 04.06.2017 12:53
Re: What is wrong? / WA#1
Posted by Mahilewets 4 Jun 2017 17:08
Missed xn=x,  yn=y.
 http://ideone.com/PnKMSH
Re: What is wrong? / WA#1
Posted by Segrey_Shustov_rus 4 Jun 2017 19:47
Thank you. I feel very sorry for such a stupid mistake...