MarioYC

Selectivo 2 - P2

Sep 2nd, 2012
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main(){
  7.     int N;
  8.     double r;
  9.    
  10.     cin >> N >> r;
  11.    
  12.     double x[100],y[100];
  13.    
  14.     for(int i = 0;i < N;++i)
  15.         cin >> x[i] >> y[i];
  16.    
  17.     double ans = 2 * acos(-1.0) * r + sqrt((double)(x[N - 1] - x[0]) * (x[N - 1] - x[0]) + (double)(y[N - 1] - y[0]) * (y[N - 1] - y[0]));
  18.    
  19.     for(int i = 0;i + 1 < N;++i)
  20.         ans += sqrt((double)(x[i + 1] - x[i]) * (x[i + 1] - x[i]) + (double)(y[i + 1] - y[i]) * (y[i + 1] - y[i]));
  21.    
  22.     printf("%.2f\n",ans);
  23.    
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment