|
|
back to boardDiscussion of Problem 1020. RopeI know the formula, but something is going wrong during the 3 test. 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. 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. 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. 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. 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. And don't forget to write x[n] = x[0]; y[n] = y[0]; after reading coordinates. |
|
|