经典DP n个鹰蛋 m层楼 刚开始是二分想法 不过当数小于二分的那个值 貌似没发判断 dp[i][j] = min(dp[i][j],max(dp[i-1][k-1],dp[i][j-k]) 选择第k层扔 若碎了 就用剩下i-1个鹰蛋来测k-1层 若没碎 就用i个鹰蛋来测上面剩下的j-k层 这样是三重循环 1000^3势必TLE 不过以二分的思想来算 1000层最多只需要10个鹰蛋就可以测出来了 所以当n大于10的时候按10来算就OK了 #include <iostream> #include…
题目传送门 /* 记忆化搜索(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…
题目链接 以前做过的一题,URAL数据强点,优化了一下. #include <iostream> #include <cstdio> #include <cstring> #include <queue> #include <map> #include <ctime> #include <cmath> #include <algorithm> using namespace std; ][]; int dfs(…
链接 Chernobyl’ Eagle on a Roof 题意 引用论文题意:有一堆共 M 个鹰蛋,一位教授想研究这些鹰蛋的坚硬度 E.他是通过不断从一幢 N 层的楼上向下扔鹰蛋来确定 E 的.当鹰蛋从第 E 层楼及以下楼层落下时是不会碎的,但从第(E+1)层楼及以上楼层向下落时会摔碎.如果鹰蛋未摔碎,还可以继续使用:但如果鹰蛋全碎了却仍未确定 E,这显然是一个失败的实验.教授希望实验是成功的.例如:若鹰蛋从第 1 层楼落下即摔碎,E=0:若鹰蛋从第 N 层楼落下仍未碎,E=N.这里假设所有的…
列表: URAL 1225 Flags URAL 1009 K-based Numbers URAL 1119 Metro URAL 1146 Maximum Sum URAL 1203 Scientific Conference URAL 1353 Milliard Vasya's Function URAL 1260 Nudnik Photographer URAL 1012 K-based Numbers. Version 2 URAL 1073 Square Country URAL 1…
题目 题目链接 你将获得 K 个鸡蛋,并可以使用一栋从 1 到 N  共有 N 层楼的建筑.每个蛋的功能都是一样的,如果一个蛋碎了,你就不能再把它掉下去,如果没有碎可以继续使用.你知道存在楼层 F ,满足 0 <= F <= N 任何从高于 F 的楼层落下的鸡蛋都会碎,从 F 楼层或比它低的楼层落下的鸡蛋都不会破.每次移动,你可以取一个鸡蛋(如果你有完整的鸡蛋)并把它从任一楼层 X 扔下(满足 1 <= X <= N).你的目标是确切地知道 F 的值是多少.无论 F 的初始值如何,…
1222. Chernobyl’ Eagles Time limit: 1.0 secondMemory limit: 64 MB A Chernobyl’ eagle has several heads (for example, the eagle on the Russian National Emblem is a very typical one, having two heads; there exist Chernobyl’ eagles having twenty-six, on…
1223: [HNOI2002]Kathy函数 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 207  Solved: 90[Submit][Status] Description Input 仅有一行,为正整数m Output 输出仅有一个正整数,表示所有的满足f(n)=n,(n<=m) 的自然数的个数. Sample Input 5 Sample Output 3 这道题的高精度模板相对又有完善,但还存在bugs,使用时尽量讲位数多开几倍.…
Eagle (AKA Mohamed Ahmed) lives in a city consists of n intersections connected by n-1 roads, in a way that can go from any intersection to any other intersection moving along some of these roads. Every day he starts walking in the city following a s…
题目链接:1223. 掷骰子模拟 有一个骰子模拟器会每次投掷的时候生成一个 1 到 6 的随机数. 不过我们在使用它时有个约束,就是使得投掷骰子时,连续 掷出数字 i 的次数不能超过 rollMax[i](i 从 1 开始编号). 现在,给你一个整数数组 rollMax 和一个整数 n,请你来计算掷 n 次骰子可得到的不同点数序列的数量. 假如两个序列中至少存在一个元素不同,就认为这两个序列是不同的.由于答案可能很大,所以请返回 模 \(10^9 + 7\) 之后的结果. 示例1: 输入:n =…