|
|
back to boardDiscussion of Problem 1020. RopeWA#3 Posted by nikita 20 Jun 2009 16:11 This is my source code: #include <iostream> #include <math.h> using namespace std; int main(){ int N; double R, ans=0.0, x1,y1,xt,yt,x,y; cin >> N >> R; cin >> x1 >> y1; xt=x1; yt=y1; for (int i=1; i<N; i++){ cin >> x >> y; ans+=sqrt((x-xt)*(x-xt)+(y-yt)*(y-yt)); xt=x; yt=y; } ans+=sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1)); ans+=2*acos(-1.0)*R; cout << floor(ans*100)/100 << endl; return 0; } P.S. cout << setprecision(2) << ans << endl; isn't Ъ way. Re: WA#3 I think You Just be careful when N = 1 |
|
|