题目传送门

 /*
记忆化搜索(DFS+DP):dp[x][y] 表示x个蛋,在y楼扔后所需要的实验次数
ans = min (ans, max (dp[x][y-i], dp[x-1][i-1]) + 1);前者表示蛋没碎,则往高处(y-i)搜索
后者表示蛋碎了,往低处(i-1)方向搜索
这样写不好,每次memset (dp)就会超时:(
详细解释:http://blog.csdn.net/fulongxu/article/details/27110435
*/
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std; const int MAXN = 1e3 + ;
const int INF = 0x3f3f3f3f;
int dp[][MAXN]; int DFS(int x, int y)
{
if (dp[x][y]) return dp[x][y];
if (x == ) {dp[x][y] = y; return y;}
if (y <= ) {dp[x][y] = y; return y;} int ans = INF;
for (int i=; i<y; ++i)
{
int tmp = max (DFS (x, y-i) + , DFS (x-, i-) + );
ans = min (ans, tmp);
} return dp[x][y] = ans;
} int main(void) //URAL 1223 Chernobyl’ Eagle on a Roof
{
//freopen ("Z.in", "r", stdin); int n, m;
while (scanf ("%d%d", &n, &m) == )
{
if (!n && !m) break;
if (n > ) n = ; printf ("%d\n", DFS (n, m));
} return ;
}

最新文章

  1. mysql 基本操作语句
  2. Centos下 为Firefox安装Flash插件
  3. Struts2的标签库(三)——控制标签
  4. Mybatis+struts2+spring整合
  5. 阅读layim代码小记,实现可以更改用户签名的方法
  6. STL源码剖析读书笔记--第6章&amp;第7章--算法与仿函数
  7. JPasswordField 中得到的字符数组转化为字符串(密码乱码问题)
  8. JMX学习一
  9. 【Java】ArrayList 的 toArray() 方法抛出 ClassCastException 异常
  10. 【The Most Important】浅谈JSP表单Post方式中文乱码问题
  11. pip 警告!The default format will switch to columns in the future
  12. Redis- 简单操作命令
  13. Solr的配置和在java中的使用
  14. [Python数据挖掘]第3章、数据探索
  15. eclipse 基础快捷键。
  16. HDU - 5952 Counting Cliques(DFS)
  17. phpmyadmin拿webshell
  18. 使用ycsb对hbase0.94.11 benchmark
  19. 解码(ByteBuffer): CharsetDecoder.decode() 与 Charset.decode() 的不同
  20. HDU1847 Good Luck in CET-4 Everybody 博弈 SG函数

热门文章

  1. 流媒体开发之开源项目live555---更改server端的帧率大小和码率大小
  2. EnumChildWindows
  3. 我遇到的错误curl: (7) Failed to connect to 127.0.0.1 port 1086: Connection refused
  4. hihoCoder 1586 Minimum 【线段树】 (ACM-ICPC国际大学生程序设计竞赛北京赛区(2017)网络赛)
  5. swt_table 回车可编辑Esc取消
  6. Ubuntu 配置 nfsserver
  7. 对soc-audio体系snd_soc_machine和snd_soc_dai_link简单理解
  8. box-sizing: border-box;的作用
  9. 分享windows自带计划任务Task schedule使用指南
  10. 【转载】浅谈Excel开发:一 Excel 开发概述