本文主要是介绍Fleecing the Raffle Gym - 101550F(概率),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
题意:
所有数选p个,但你可以加入a个自己的数。求选到的数中你加入数的个数恰好为1个的概率
思路:
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>using namespace std;
typedef long long ll;const int maxn = 1e7 + 7;
double C(int n,int p,int a) {double ans = 1.0;for(int i = 1;i <= p;i++) {ans *= (n - i + 1);ans /= (n + a - i + 1);}return ans * a * p / (n - p + 1);
}int main() {int n,p;scanf("%d%d",&n,&p);int a = n / (p - 1);double ans = C(n,p,a);printf("%.10f\n",ans);return 0;
}
这篇关于Fleecing the Raffle Gym - 101550F(概率)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!