题目地址:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1875
思路:
红书上分析:
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
LL f[105][70];
void prepare()
{
for(int i=1;i<=101;i++)
{
for(int j=1;j<=64;j++)
{
f[i][j]=f[i-1][j-1]+f[i][j-1]+1;
}
}
}
int main()
{
prepare();
int k;LL n;
while(scanf("%d%lld",&k,&n)!=EOF&&k)
{
int ans=-1;
for(int i=0;i<=63;i++)
{
if(f[k][i]>=n)
{
ans=i;
break;
}
}
if(ans==-1) printf("More than 63 trials needed.\n");
else printf("%d\n",ans);
}
return 0;
}