fork(1) download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath>
  4. using std::cin;
  5. using std::cout;
  6. using std::endl;
  7. using std::setprecision;
  8. using std::fixed;
  9. int main()
  10. {
  11. int n;
  12. double r,s=0,x,y,x0,y0,xn,yn;
  13. cin >> n >> r;
  14. if (n==1) {
  15. cin >> x >> y;
  16. xn=x, yn=y;
  17. }
  18. if (n>1) {
  19.  
  20. cin >> x >> y;
  21. xn=x, yn=y;
  22. for (int i=1;i<=n-1;i++) {
  23. cin >> x0 >> y0;
  24. s=s+sqrt((x0-x)*(x0-x)+(y0-y)*(y0-y));
  25. x=x0;y=y0;
  26. }
  27. s=s+sqrt((xn-x)*(xn-x)+(yn-y)*(yn-y));
  28. }
  29. s=s+2*3.1415*r;
  30. cout << fixed << setprecision(2) << s << endl;
  31.  
  32. return 0;
  33. }
Success #stdin #stdout 0s 15240KB
stdin
4 1
0.0 0.0
2.0 0.0
2.0 2.0
0.0 2.0
stdout
14.28