Advertisement
IlidanBabyRage

string.cpp

Jun 5th, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #define PI 3.1415926
  4.  
  5. using namespace std;
  6.  
  7. int main(){
  8.    
  9.     int n;
  10.     double r, x0, y0, x1, y1, x2, y2, ans = 0;
  11.     cin >> n >> r;
  12.     ans += 2 * PI * r;
  13.     if (n == 1){
  14.         cout << (floor(ans * 100 + 0.5)) / 100. << endl;
  15.         return 0;
  16.     }
  17.     cin >> x0 >> y0;
  18.     x1 = x0, y1 = y0;
  19.     for (int i = 1; i < n; i++){
  20.         cin >> x2 >> y2;
  21.         ans += sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
  22.         x1 = x2;
  23.         y1 = y2;
  24.     }
  25.     ans += sqrt((x2 - x0) * (x2 - x0) + (y2 - y0) * (y2 - y0));
  26.     cout << (floor(ans * 100 + 0.5)) / 100. << endl;
  27.  
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement