The 2018 ACM-ICPC Chinese Collegiate Programming Contest Take Your Seat

  

 /*

证明过程如下 :
第一种情况:
按1到n的顺序上飞机,1会随意选一个,剩下的上去时若与自己序号相同的
座位空就坐下去,若被占了就也会随意选一个。
求最后一个人坐在应坐位置的概率

*/

                

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstring>
 4 #include <string>
 5 #include <algorithm>
 6 #include <utility>
 7 #include <vector>
 8 #include <map>
 9 #include <queue>
10 #include <stack>
11 #include <cstdlib>
12 typedef long long ll;
13 #define lowbit(x) (x&(-x))
14 #define ls l,m,rt<<1
15 #define rs m+1,r,rt<<1|1
16 using namespace std;
17 double x=0.5;
18 double y=1.0;
19 int main()
20 {
21     int t,n,m;
22     scanf("%d",&t);
23     for(int i=1;i<=t;i++)
24     {
25         scanf("%d%d",&n,&m);
26         if(n==1){//特判
27             printf("Case #%d: %.6f %.6f\n",i,y,1.0*(m+1)/(2*m));
28         }
29         else{
30             printf("Case #%d: %.6f %.6f\n",i,x,1.0*(m+1)/(2*m));
31         }
32     }
33     return 0;
34 }

猜你喜欢

转载自www.cnblogs.com/tingtin/p/9328132.html