All the first number plus Ri, i.e., changes the interval [0,2Ri], consider the inclusion and exclusion, the receiving dismissed interval [0, + oo) - [ 2Ri, + oo), then [2Ri, + oo) Order $ bi = ai-2Ri $, are equivalent to the range [0, + oo)
is transformed and the number does not exceed the number of programs for the sake of b n positive infinity range, and found that wild guess $ b ^ {n} / n! $, violence can be cumulative
1 #include<bits/stdc++.h> 2 using namespace std; 3 #define ld long double 4 int t,n,x,y,a[11]; 5 ld ans; 6 ld calc(int k){ 7 if (k<=0)return 0; 8 ld ans=1; 9 for(int i=1;i<=n;i++)ans=ans*k/i; 10 return ans; 11 } 12 int main(){ 13 scanf("%d",&t); 14 while (t--){ 15 scanf("%d%d%d",&n,&x,&y); 16 ans=0; 17 for(int i=0;i<n;i++){ 18 scanf("%d",&a[i]); 19 x+=a[i]; 20 y+=a[i]; 21 a[i]=a[i]*2; 22 } 23 for(int i=0;i<(1<<n);i++){ 24 int p=1,s=0; 25 for(int j=0;j<n;j++) 26 if (i&(1<<j)){ 27 p*=-1; 28 s+=a[j]; 29 } 30 ans+=p*(calc(y-s)-calc(x-s)); 31 } 32 for(int i=0;i<n;i++)ans/=a[i]; 33 printf("%.9Lf\n",ans); 34 } 35 }