JZ junior OJ 1565. [GDKOI] mystery Villa

Title Description

Tsui Hang Village is a mysterious Villa, not because it gave birth to the great man Sun Yat-sen, is more mysterious ghost Hill, there are only N, M rabbits, of course, you. Where every second:

1. Exactly two creatures encountered.

2. The probability of encounter between any two organisms are equal.

If two rabbits meet, nothing happens; if two ghosts meet, they will tussle with each other, eventually die together; If you encounter a ghost rabbit, the rabbit will be eaten; if you encounter a ghost, ha ha. . . . symbol to see you; if you come across a rabbit, then you can choose to kill or not to kill (equal probability).

Q. Can you live to see the probability of the symbol.
 

Entry

The first line of two integers N, M.

Export

A real number, the probability that you survived, 6 decimal place.
 

Sample input

0 0

Sample Output

1.000000
 

Data range limit

 
 

prompt

【limit】

0<=N,M<=1000。

For 20% of the data: N, M <= 10.

For 30% of the data: M = 0.
 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 double n,m,a,sum=1;
 4 int main()
 5 {
 6     cin>>n>>m;
 7     a=m+1+n;
 8     if(int(n)%2==0)
 9     printf("%.6lf",1/(n+1));
10     else
11     printf("%.6lf",0);
12     return 0;
13 }

Guess you like

Origin www.cnblogs.com/anbujingying/p/11305843.html