Egg Problem

时间限制(普通/Java):1000MS/3000MS 运行内存限制:65536KByte
总提交: 22 测试通过: 7

描述

There is a very interesting problem described as follows:

You are given two eggs.

You have access to a 100-storey building.

An egg that survives a fall can be used again.

A broken egg must be discarded.

The effect of a fall is the same for all eggs.

If an egg breaks when dropped, then it would break if dropped from
a higher window.

If an egg survives a fall then it would survive a shorter
fall.

It is not ruled out that the first-floor windows break eggs, nor
is it ruled out that the 100th-floor windows do not cause an egg to break.

You need to figure out the highest floor an egg can be dropped
without breaking. The question is how many drops you need to make.

Now, I want to know how to solve this problem for any number of eggs and any
storeys. Can you help me?

输入

In the first line there is an integer T (T <= 10000), indicates the number
of test cases.

In each case, there are two integers n and m (1 <= n <= 15, 1 <= m
<= 100000), which are the number of eggs and storeys.

输出

For each case, the output format is “Case c: ans”.

c is the case number start from 1.

ans is the answer of this problem.

样例输入

2
2 100
3 100

样例输出

Case 1: 14
Case 2: 9

题目来源

2011年绍兴市赛

原理:http://blog.sina.com.cn/s/blog_6c813dbd0101bh98.html

推导过程:http://blog.csdn.net/joylnwang/article/details/6769160

 #include <stdio.h>
int dp[][];
void Init(){
for(int i=; i<=; i++){
for(int j=; j<=; j++){
if(i == ) dp[i][j] = j;
else if(i == j) dp[i][j] = (<<i)-;
else if(i >= j) dp[i][j] = dp[j][j];
else if(i < j) dp[i][j] = dp[i-][j-] + + dp[i][j-];
if(dp[i][j]>=){
break;
}
}
}
}
int main()
{
int T;
Init();
scanf("%d", &T);
for(int cas=; cas<=T; cas++){
int n, m;
scanf("%d %d", &n, &m);
for(int i=; ; i++){
if(dp[n][i] >= m){
printf("Case %d: %d\n", cas, i);
break;
}
}
}
return ;
}

toj 3761 Egg Problem (好题~~)的更多相关文章

  1. 2 Egg Problem

    继续我们的推理问题之旅,今天我们要对付的是一个Google的面试题:Two Egg Problem. 我们开始吧! No.2  Google Interview Puzzle : 2 Egg Prob ...

  2. 【BZOJ1000】A+B Problem ★BZOJ1000题达成★

    [BZOJ1000]A+B Problem Description 输入两个数字,输出它们之和 Input 一行两个数字A,B(0<=A,B<100) Output 输出这两个数字之和 S ...

  3. hdu-5867 Water problem(水题)

    题目链接: Water problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Othe ...

  4. Poj1207 The 3n + 1 problem(水题(数据)+陷阱)

    一.Description Problems in Computer Science are often classified as belonging to a certain class of p ...

  5. Codeforces - 1194B - Yet Another Crosses Problem - 水题

    https://codeforc.es/contest/1194/problem/B 好像也没什么思维,就是一个水题,不过蛮有趣的.意思是找缺黑色最少的行列十字.用O(n)的空间预处理掉一维,然后用O ...

  6. HDU 5475:An easy problem 这题也能用线段树做???

    An easy problem Time Limit: 8000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...

  7. HDOJ(HDU) 2123 An easy problem(简单题...)

    Problem Description In this problem you need to make a multiply table of N * N ,just like the sample ...

  8. codeforces 340C Tourist Problem(公式题)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Tourist Problem Iahub is a big fan of tou ...

  9. HDU 5832 A water problem 水题

    A water problem 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5832 Description Two planets named H ...

随机推荐

  1. python 进程事件

    1.作用 通过信号量,控制全部进程进入阻塞状态,也可以通过控制信号量,解除全部进程的阻塞 注意:定义的事件对象,默认状态是阻塞 2.常用方法 """ 对象.set() 作 ...

  2. Qt Installer Framework翻译(6-0)

    Qt安装程序框架示例 这些示例说明了如何使用组件脚本来自定义安装程序. Change Installer UI Example 使用组件脚本修改安装程序UI. Component Error Exam ...

  3. Qt Installer Framework翻译(7-2)

    包文件夹 安装程序包含的组件,要么是内嵌的,要么可以从远程存储库加载.在这两种情况下,都需要为组件使用一种安装程序可以读取的文件格式和结构. 包文件夹结构 将所有组件放在相同的根文件夹中,即包文件夹. ...

  4. python3中的RE(正则表达式)

    记录大佬的 整理 原文来自:https://blog.csdn.net/weixin_40136018/article/details/81183504 1.引入正则模块(Regular Expres ...

  5. GP工作室—系统设计

    团队作业第二次作业--系统设计 问题 答案 这个作业属于哪个课程 软件工程 这个作业要求在哪里 作业要求 团队名称 GP工作室 这个作业的目标 对项目软件进行更为详细的系统性设计 按照本游戏的设计要求 ...

  6. beta版本发布说明与总结

    1.发布说明: 软件介绍: deta版本的发布最终是一个可安装使用的窗体程序,已经由Alpha版本的应用解决方案完成到一个程序: deta版本解决了Alpha版本遗留的软件技术方面错误问题,以及针对有 ...

  7. c#数字图像处理(一)Bitmap类、 Bitmapdata类和 Graphics类

    Bitmap类. Bitmapdata类和 Graphics类是C#图像处理中最重要的3个类,如果要用C#进行图像处理,就一定要掌握它们. 1.1 Bitmap类Bitmap对象封装了GDI+中的一个 ...

  8. PSR标准规范

    PSR标准规范 基本代码规范 PHP代码文件 必须 以 不带 BOM 的 UTF-8 编码: 类的命名 必须 遵循 StudlyCaps 大写开头的驼峰命名规范: 类中的常量所有字母都 必须 大写,单 ...

  9. vue响应式原理的实现

    响应式实现的原理---如何监控数据的变化:两种方法 Vue 2.x defineProperty(es5) Vue 3.x Proxy(es6) 语法:Object.defineProperty(参数 ...

  10. DataTable 相关

    1.对表的初始化 //创建表 DataTable table = new DataTable(); //添加列 table.Columns.Add("ID", typeof(Int ...