fork(4) download
  1. // iostream is too mainstream
  2. #include <cstdio>
  3. // bitch please
  4. #include <iostream>
  5. #include <vector>
  6. #include <set>
  7. #include <map>
  8. #include <string>
  9. #include <queue>
  10. #include <stack>
  11. #include <algorithm>
  12. #include <iomanip>
  13. #define dibs reserve
  14. #define OVER9000 1234567890
  15. #define patkan 9
  16. #define tisic 47
  17. #define soclose 10e-7
  18. #define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
  19. #define chocolate win
  20. #define ff first
  21. #define ss second
  22. #define abs(x) ((x < 0)?-(x):(x))
  23. // mylittlepony
  24. using namespace std;
  25.  
  26. int main() {
  27. // freopen("zeriba.in","r",stdin);
  28. int T;
  29. scanf(" %d",&T);
  30.  
  31. for(int t =0; t < T; t++) {
  32. int N;
  33. scanf(" %d",&N);
  34. printf("Case %d: ",t+1);
  35. vector<int> L(N);
  36. for(int i =0; i < N; i++) scanf(" %d",&L[i]);
  37.  
  38. // possible?
  39. int S =0;
  40. bool ok =true;
  41. for(int i =0; i < N; i++) S +=L[i];
  42. for(int i =0; i < N; i++) if(L[i]*2 >= S) ok =false;
  43. if(!ok) {printf("can't form a convex polygon\n"); continue;}
  44.  
  45. double Rmin =soclose, Rmax =1e+7;
  46. for(int i =0; i < N; i++) Rmin =max(Rmin,L[i]/2.0)+soclose;
  47. while(Rmax-Rmin > soclose) {
  48. double R =(Rmax+Rmin)/2;
  49. double ang =0;
  50. for(int i =0; i < N; i++) ang +=asin(1.0*L[i]/(2*R));
  51. if(ang > 4*atan(1)) Rmin =R;
  52. else Rmax =R;}
  53.  
  54. printf("%.4f\n",Rmax);}
  55. return 0;}
  56.  
  57. // look at my code
  58. // my code is amazing
Success #stdin #stdout 0s 3432KB
stdin
2
4
1 1 1 1
3
1 1 1
stdout
Case 1: 0.7071
Case 2: 0.5774