I am giving extra test case :
Input:
- Code: Select all
120000 50000 100000
400000 50000 200000
0 0 0
Output:
- Code: Select all
Case 1: 9000.00
Case 2: 55000.00
Here hints to solve this problem.
if
M<MIN then output must be 0.00
if
M>MAX then output .2*(M-MAX)+.1*(MAX-MIN)
But if
MIN<=M<=MAX then you have to calculate probability based calculation.
Let TotalSpace=(MAX-MIN+1)*(MAX-MIN+1+1)/2. --> (Total combinations of s1 and s2 ).
Now evaluate below code efficiently.
- Code: Select all
res=0.0;
for(i=MIN;i<=M;i++)
for(j=M;j<=MAX;j++)
res+=.1*(M-i)/TotalSpace;
for(i=MIN;i<M;i++)
for(j=i;j<M;j++){
res+=.2*(M-j)/TotalSpace;
res+=.1*(j-i)/TotalSpace;
}
print res.
MIN,MAX and M are defined in problem statement.