|
|
back to boardDiscussion of Problem 1020. RopeWrong Answer Test #3 Please Help! #include<iostream> #include<stdio.h> #include<math.h> using namespace std; double distance(double x1, double y1, double x2, double y2); int main(){ int n ; double r; cin>>n>>r; double x1,y1,x2,y2; cin>>x1>>y1; cin>>x2>>y2; double ans = 0; //float pi = (float)22/(float)7; double pi=2*acos(0.0); //cout<<pi<<endl; ans = distance(x1,y1,x2,y2); //cout<<ans<<endl; int temp = n; temp = temp-2; double x3,y3; x3=x2; y3=y2; while(temp>0){ x2=x3; y2=y3; cin>>x3>>y3; ans = ans + distance(x2,y2,x3,y3); // cout<<ans<<endl; temp--; } ans = ans + distance(x1,y1,x3,y3); //distance of last and first point double con = 2*pi*r; ans = ans + con; cout.precision(2); cout<<fixed<<ans<<endl; return 0; } double distance(double x1, double y1, double x2, double y2){ x1 = x1-x2; y1 = y1-y2; x1 = x1*x1; y1 = y1*y1; double sum = x1+y1; sum = sqrt(sum); return sum; } Re: Wrong Answer Test #3 Please Help! try this test 1 1 0.0 0.0 //float pi = (float)22/(float)7; - lol :-)))) Re: Wrong Answer Test #3 Please Help! Thanks :) I was trying all sorts of things actually with the value of pi lol :P Re: Wrong Answer Test #3 Please Help! Posted by Karthic 19 Jan 2012 00:05 What's the expected output for this? 1 1 0.0 0.0 Re: Wrong Answer Test #3 Please Help! Posted by Darwesh 14 Sep 2012 05:03 but i've trid this still its wrong. even it gives wrong on test 1 |
|
|