fork download
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6. long double R[10000];
  7. long double Z[10000];
  8.  
  9. long double PI = 3.14159265354;
  10.  
  11. inline long double FInter(long double h,int i){
  12. //clog << h <<" "<<Z[i]<<" "<<R[i];
  13. if (h > Z[i] + R[i]) return 0;
  14. if (h < Z[i] - R[i]) return 4.0/3.0 * PI * R[i]*R[i]*R[i];
  15. h-=Z[i];
  16. bool z;
  17. if (h < 0) z = true;
  18. else z = false;
  19. if (h < 0) h = -h;
  20. h/=R[i];
  21. h = 1 - h;
  22. long double e = 3.0;
  23. long double pp = (h - 1.0/e + (1 - h) * (1 - h) * (1 - h)/e);
  24. long double PreAns = R[i]*R[i]*R[i] * PI * pp;
  25. if (z) PreAns = 4.0/3.0 * PI * R[i]*R[i]*R[i] - PreAns;
  26. //clog <<" = "<<PreAns<<endl;
  27. return PreAns;
  28. }
  29.  
  30. inline long double Inter(long double L, long double R,int n){
  31. return FInter(L,n) - FInter(R,n);
  32. }
  33.  
  34. int main(){
  35. int N,S;
  36. cin >> N >> S;
  37. long double LL = 0;
  38. for (int i=0;i<N;i++)
  39. cin >> R[i] >> Z[i] >> Z[i] >> Z[i];
  40.  
  41. long double fix = 100000.0*100000.0*100000.0;
  42. for (int i=0;i<N;i++)
  43. fix -= 4.0/3.0 * PI * R[i]*R[i]*R[i];
  44. fix/=S;
  45.  
  46. for (int i=0;i<S;i++){
  47. long double R = 100000;
  48. long double L = LL;
  49. long double K;
  50. while (R - L > 1e-10){
  51. K = (L+R)/2;
  52. long double F = (K - LL) * 100000.0*100000.0;
  53. for (int i=0;i<N;i++)
  54. F-= Inter(LL,K,i);
  55. if (F > fix)
  56. R = K;
  57. else L = K;
  58. }
  59. cout <<setprecision(15) << (L - LL)/1000.0<<endl;
  60. LL = L;
  61. }
  62.  
  63. }
Time limit exceeded #stdin #stdout 5s 3328KB
stdin
Standard input is empty
stdout
Standard output is empty