Thinking
First, we can ignore the event of a tie, because if we filter out the event of a tie, the end result remains the same.
We remember Alice probability to lose $ p $, the probability of winning for the $ 1-p $, when Alice on hand $ i $ candy pieces, the final probability of winning is $ f_i $.
Then we can list the transfer equation:
$f0=0,f{n+m}=1$
$f{i}=(1-p)f{i-1}+pf_{i+1},0 < i < n+m$
Obviously this stuff is not directly transferred, if $ n, m $ relatively small Gaussian elimination we can solve the equation, but this problem is data range 10 ^ 5 $ $, using the Gaussian elimination will $ TLE $.
So we manually solve the equation. (Funny
Each of the F $ I $ $ k_if expressed as a form of {i + 1} $ a.
$ F_0 = 0f_1 $, therefore $ k_0 = 0 $.
$fi=(1-p)f{i-1}+pf{i+1}=(1-p)k{i-1}fi+pf{i+1}Rightarrow (1-(1-p)k{i-1})f_i=pf{i+1}Rightarrow fi=frac{p}{1-(1-p)k{i-1}}f{i+1}Rightarrow k_i=frac{p}{1-(1-p)k{i-1}}$
So we can $ O (n) $ introduced all of the $ k $.
Because $ f_ {n + m large columns NOWCODER14962 Alice and Bob bet candy solving report } = 1 $, we can pour the launch all $ f $.
The final answer is F $ n-Prod = {I} = ^ {n-m-n-+ $ K_i. 1}. Note that Japanese sentence $ n = 0 $ case.
Code
#include<bits/stdc++.h>
using namespace std;
#define i64 long long
#define f80 long double
#define rgt register
#define fp( i, b, e ) for ( int i(b), I(e); i <= I; ++i )
#define fd( i, b, e ) for ( int i(b), I(e); i >= I; --i )
#define go( i, b ) for ( int i(b), v(to[i]); i; v = to[i = nxt[i]] )
template<typename T> inline bool cmax( T &x, T y ){ return x < y ? x = y, 1 : 0; }
template<typename T> inline bool cmin( T &x, T y ){ return y < x ? x = y, 1 : 0; }
int N, l, r, M, L, R;
double p, s, t;
signed main(){
cin >> N >> l >> r >> M >> L >> R;
if ( !N ) return printf( "0.00000n" ), 0;
fp( i, l, r ) fp( j, L, R )
s += i != j ? 1 : 0, p += i > j ? 1 : 0;
p /= s, s = 1, t = 0;
fp( i, 1, N + M - 1 ){
t = p / (1 - (1 - p) * t);
if ( i >= N ) s *= t;
} printf( "%.5lfn", s );
return 0;
}