fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <math.h>
  4. #include <stdio.h>
  5. using namespace std;
  6.  
  7. int main(){
  8. double ang, s, sq, r2, res, M[500];
  9. int n, r, pts;
  10. while(cin >> n >> r, n + r != 0){
  11. for(int i = 0; i < n; i++){
  12. cin >> M[i];
  13. M[i] = M[i] * M_PI / 180;
  14. }
  15. sort(M, M + n);
  16. res = M_PI * r * r * n * (n - 1) * (n - 2) / 6;
  17. r2 = r * r / 2.0;
  18. sq = M_PI * r * r;
  19. for(int i = 0; i < n; i++){
  20. for(int j = i + 1; j < n; j++){
  21. ang = M[j] - M[i];
  22. if(ang < M_PI){
  23. s = r2 * (ang - sin(ang));
  24. }else{
  25. ang = 2 * M_PI - ang;
  26. s = sq - r2 * (ang - sin(ang));
  27. }
  28. pts = n - (j - i + 1);
  29. res = res - s * pts;
  30. pts = n - 2 - pts;
  31. res = res - (sq - s) * pts;
  32. }
  33. }
  34. printf("%.f\n", res);
  35. }
  36.  
  37. return 0;
  38. }
Success #stdin #stdout 0s 4360KB
stdin
5 10
10.00
100.00
300.00
310.00
320.00
3 20
10.00
100.00
300.00
0 0
stdout
286
320