fork(3) download
  1. #include <iostream>
  2. #include <math.h>
  3. #include <iomanip>
  4.  
  5. using namespace std;
  6. int n;
  7. long long int k;
  8. long double t1,t2,t3,b1,b2;
  9. int main()
  10. {
  11. cin >>n>>k;
  12. if (n==3)
  13. {
  14. long double x1,x2,x3,y1,y2,y3;
  15. cin >> x1 >> y1;
  16. cin >> x2 >> y2;
  17. cin >> x3 >> y3;
  18. t1=sqrt(pow(x1-x2,2)+pow(y1-y2,2));
  19. t2=sqrt(pow(x3-x2,2)+pow(y3-y2,2));
  20. t3=sqrt(pow(x1-x3,2)+pow(y1-y3,2));
  21. long double p,P;
  22. p=0.5*(t1+t2+t3);
  23. p=sqrt(p*(p-t1)*(p-t2)*(p-t3));
  24. P=p+k*(t1+t2+t3)+0.5*M_PI*pow(k,2);
  25. cout << fixed << setprecision(6)<<P<<endl;
  26. }
  27. else if (n==4)
  28. {
  29. long double p1,p2,p3,r1,r2,r3,p4,r4;
  30. cin >> p1 >> r1;
  31. cin >> p2 >> r2;
  32. cin >> p3 >> r3;
  33. cin >> p4 >> r4;
  34. b1=sqrt(pow(p1-p2,2)+pow(r1-r2,2));
  35. b2=sqrt(pow(p3-p2,2)+pow(r3-r2,2));
  36. long double P;
  37. P=b1*b2+k*(2*b1+2*b2)+M_PI*pow(k,2);
  38. cout << fixed << setprecision(6)<<P<<endl;
  39.  
  40. }
  41. return 0;
  42. }
Success #stdin #stdout 0s 3460KB
stdin
4 1
0 0
0 1
1 1
1 0
stdout
8.141593