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

I know the formula, but something is going wrong during the 3 test.
Posted by Mihran Muradyan (Fizmat) 6 May 2009 17:33
I know the formula, but something is going wrong during the 3 test.



#include"iostream.h"
#include"math.h"
double a[1000],l=0,x[1000],y[1000];
int n,i,r;
int main()
{
    cin>>n>>r;
    for(i=0;i<n;i++)
    {
        cin>>x[i];    cin>>y[i];
    }
    for(i=0;i<n;i++)
        l=l+sqrt((x[i]-x[i+1])*(x[i]-x[i+1])+(y[i]-y[i+1])*(y[i]-y[i+1]));
    cout<<l+((6.28)*r)<<endl;
    return 0;
}

Edited by author 06.05.2009 19:34
Re: I know the formula, but something is going wrong during the 3 test.
Posted by Aram Taranyan (YSU) 6 May 2009 18:56
Can I see your solution,otherwise I can't help you
Re: I know the formula, but something is going wrong during the 3 test.
Posted by Gevorg Soghomonyan(YSU) 6 May 2009 20:48
You can't put 6.28
you can put 2*acos(-1) you may use
#include<iostream>
#include<iomanip>
using namespace std;
.
.
.
cout<<fixed<<setprecision(2)<<...;
Re: I know the formula, but something is going wrong during the 3 test.
Posted by Aram Taranyan (YSU) 6 May 2009 20:54
Yes,use acos(-1) and include math.h,Gevorg :)



Edited by author 06.05.2009 20:56
Re: I know the formula, but something is going wrong during the 3 test.
Posted by Aram Taranyan (YSU) 6 May 2009 21:01
By the way,you have a[1000],but you don't use it ! P.S You can solve this without any array!
Re: I know the formula, but something is going wrong during the 3 test.
Posted by Sergey Lazarev (MSU TB) 7 May 2009 02:37
And don't forget to write
x[n] = x[0];
y[n] = y[0];
after reading coordinates.