fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. const long double pi=2*acos(-1.0);
  4. const long double eps=1e-8;
  5. long double Pow(long double x,int i){
  6. long double ret=1.0;
  7. while(i--){
  8. ret*=x;
  9. }
  10. return ret;
  11. }
  12. int main(){
  13. int t;
  14. cin>>t;
  15. for(int z=1;z<=t;z++){
  16. long long int n,sl,st;
  17. long double a,b;
  18. cin>>n;
  19. long long arr[n+1],m[2*n+1];
  20. for(int i=n;i>=0;i--){
  21. cin>>arr[i];
  22. }
  23. cin>>a>>b>>sl>>st;
  24. long double y[st+1];
  25. long double d=(b-a)/(long double)(st);
  26. for(int i=0;i<=st;i++){
  27. long double x=a+d*(long double)(i);
  28. y[i]=0;
  29. for(int j=0;j<=n;j++){
  30. y[i]+=(Pow(x,j)*(long double)(arr[j]));
  31. }
  32. //y[i]=fabs(y[i]);
  33. }
  34. long double fa=0,th=(pi/(long double)(sl));
  35. for(int i=0;i<st;i++){
  36. long double aa=min(y[i],y[i+1]);
  37. long double bb=max(y[i],y[i+1]);
  38. long double h;
  39. if(aa!=bb){
  40. h=bb*d/(bb-aa);
  41. }
  42. aa=((long double)(sl)*aa*aa*sin(th))/2;
  43. bb=((long double)(sl)*bb*bb*sin(th))/2;
  44. if((bb-aa)<eps){
  45. fa+=(aa*d);
  46. continue;
  47. }
  48. long double x=(bb*h)/3;
  49. long double xx=(aa*(h-d))/3;
  50. fa+=(x-xx);
  51. }
  52. memset(m,0,sizeof(m));
  53. for(int i=0;i<=n;i++){
  54. for(int j=0;j<=n;j++){
  55. m[i+j]+=(arr[i]*arr[j]);
  56. }
  57. }
  58. long double tv=0;
  59. for(int i=0;i<=(n*2);i++){
  60. tv+=(m[i]*((Pow(b,i+1)-Pow(a,i+1))/(long double)(i+1)));
  61. }
  62. tv*=pi;
  63. tv/=2.0;
  64. printf("Case %d: %.4Lf\n",z,((tv-fa)/tv)*100.0);
  65. }
  66. return 0;
  67. }
  68.  
Success #stdin #stdout 0s 3140KB
stdin
Standard input is empty
stdout
Standard output is empty