# 【URAL 1223】Chernobyl’ Eagle on a Roof（传说中的DP神优化之鹰蛋）

【URAL 1223】Chernobyl’ Eagle on a Roof（传说中的DP神优化之鹰蛋）

dp[i][j]表示i颗鹰蛋在j层楼实验的最少次数。

dp[i][j]=min1<=m<=j[max(dp[i][m1],dp[i1][jm])+1]$dp[i][j] = min_{1 <= m <= j}[max(dp[i][m-1],dp[i-1][j-m])+1]$

#include <iostream>
#include <cmath>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <climits>
#include <ctime>
#include <cstring>
#include <queue>
#include <stack>
#include <list>
#include <algorithm>
#include <map>
#include <set>
#define LL long long
#define Pr pair<int,int>
#define fwrite(ch) freopen(ch,"w",stdout)

using namespace std;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const double eps = 1e-8;
const int maxn = 1123;

int dp[10][maxn];

int main()
{
//fwrite("");

int n,m;

while(~scanf("%d%d",&m,&n) && (n+m))
{
if(m >= ceil(log((n+1)*1.0)/log(2.0)))
printf("%d\n",(int)ceil(log((n+1)*1.0)/log(2.0)));
else
{
memset(dp,0,sizeof(dp));

for(int i = 1; i <= n; ++i) dp[1][i] = i;

for(int i = 2; i <= m; ++i)
{
for(int j = 1; j <= n; ++j)
{
dp[i][j] = dp[i][j-1]+1;
for(int k = 1; k < j; ++k)
{
dp[i][j] = min(dp[i][j],max(dp[i][k-1],dp[i-1][j-k])+1);
}
}
}

printf("%d\n",dp[m][n]);
}
}

return 0;
}