fork(1) download
  1. #include <iostream>
  2. #include <iomanip>
  3. #define _USE_MATH_DEFINES
  4. #include <cmath>
  5. #define M_PI 3.14159265358979323846
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11. long long n,k,x,y;
  12. long double p,a,b,c;
  13. cin>>n>>k;
  14. long double tab[n][2];
  15. for(int i=0; i<n; i++)
  16. {
  17. for(int j=0; j<2; j++)
  18. {
  19. cin>>tab[i][j];
  20. tab[i][j]*=1.0;
  21. }
  22. }
  23. if(tab[0][0]!=0&&tab[0][1]!=0)
  24. {
  25. x=tab[0][0];
  26. y=tab[0][1];
  27. for(int i=0; i<n; i++)
  28. {
  29. for(int j=0; j<2; j++)
  30. {
  31. if(j==0)
  32. tab[i][j]-=x;
  33. else if(j==1)
  34. tab[i][j]-=y;
  35. }
  36. }
  37. }
  38. if(n==4)
  39. {
  40. a=sqrt(tab[1][0]*tab[1][0]+tab[1][1]*tab[1][1]);
  41. b=sqrt(tab[3][0]*tab[3][0]+tab[3][1]*tab[3][1]);
  42. p=a*b;
  43. p=p+2*(a*k)+2*(b*k)+M_PI*k*k;
  44. cout<<fixed;
  45. cout<<setprecision(6)<<p;
  46. }
  47. else if(n==3)
  48. {
  49. a=sqrt(tab[1][0]*tab[1][0]+tab[1][1]*tab[1][1]);
  50. b=sqrt(tab[2][0]*tab[2][0]+tab[2][1]*tab[2][1]);
  51. tab[2][0]-=tab[2][0];
  52. tab[2][1]-=tab[2][1];
  53. tab[1][0]-=tab[2][0];
  54. tab[1][1]-=tab[2][1];
  55. c=sqrt(tab[1][0]*tab[1][0]+tab[1][1]*tab[1][1]);
  56. p=sqrt((a+b+c)/2*((a+b+c)/2-a)*((a+b+c)/2-b)*((a+b+c)/2-c));
  57. p=p+k*a+k*b+k*c+M_PI*k*k;
  58. cout<<fixed;
  59. cout<<setprecision(6)<<p;
  60. }
  61. return 0;
  62. }
Success #stdin #stdout 0s 4528KB
stdin
4 1000000000
0 0
0 1
1 1
1 0
stdout
3141592657589793281.000000