fork download
  1. #include<bits/stdc++.h>
  2.  
  3. #define pi acos(-1)
  4. #define all(x) (x).begin(),(x).end()
  5. #define fill(x,y) memset(x, y, sizeof(x))
  6. #define trace(x) cout << #x << " = " << x << endl
  7. #define bug cout << "Bug check" << endl
  8. #define endl '\n'
  9.  
  10. using namespace std;
  11.  
  12. int main(){
  13. //freopen("in.txt","r", stdin);
  14. //freopen("out.txt","w", stdout);
  15.  
  16. //ios::sync_with_stdio(0);
  17. //cin.tie(0);
  18.  
  19. int n; cin >> n;
  20. double r; cin >> r;
  21.  
  22. vector < pair<double,double> > v(n);
  23.  
  24. for(int i=0;i<n;i++){
  25. double x,y; cin >> x >> y;
  26. v[i].first = x;
  27. v[i].second = y;
  28. }
  29.  
  30. double d = sqrt((v[0].first-v[n-1].first)*(v[0].first-v[n-1].first) + (v[0].second-v[n-1].second)*(v[0].second-v[n-1].second));
  31.  
  32. for(int i=0;i<n-1;i++){
  33. d+= sqrt((v[i].first-v[i+1].first)*(v[i].first-v[i+1].first) + (v[i].second-v[i+1].second)*(v[i].second-v[i+1].second));
  34. }
  35.  
  36. d+= n*(2.0*pi*r/n);
  37.  
  38. printf("%.2lf\n", d);
  39. return 0;
  40. }
Success #stdin #stdout 0s 4444KB
stdin
4 1
0.0 0.0
2.0 0.0
2.0 2.0
0.0 2.0
stdout
14.28