题目:https://nanti.jisuanke.com/t/17415
题意:有n个名字在盒子中,抽奖的时候抽p个名字,你可选择作弊来提高自己的中奖几率,就是在盒子中多放些自己的名字(已有一个),求最大几率(赛下看真难懂
思路:
所有题解:NCPC 2016 Presentation of solutions - NTNU
代码:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,p;
cin >> n >> p;
double maxn = 1.0*p/(n+1),cur;
for(int i = 2; ;i++)
{
cur = maxn*i/(i-1) * (n-p+i)/(n+i);
if(cur >= maxn)
maxn = cur;
else
break;
}
cout << fixed << setprecision(8) << maxn << "\n";
return 0;
}