HDU2201

水~

分析:n,m。对于第一个人不抽到m号座位概率为(n-1)/n,第二个人为(n-2)/(n-1).。。。第m个人为1/(n-m+1).。。。

相乘之后则为 1/n

View Code
 1 /*
 2 水~
 3 */
 4 #include<stdio.h>
 5 #include<string.h>
 6 #include<stdlib.h>
 7 #include<algorithm>
 8 #include<iostream>
 9 #include<queue>
10 #include<stack>
11 #include<math.h>
12 #include<map>
13 using namespace std;
14 const int maxn = 1005;
15 int main(){
16     int n,m;
17     while( scanf("%d%d",&n,&m)==2 ){
18         printf("%.2lf\n",1.0/(1.0*n));
19     }
20     return 0;
21 }
keep moving...
原文地址:https://www.cnblogs.com/xxx0624/p/2952588.html