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. 如何添加.pch文件

    1.Create a pch , call name is project+xxx.pch For example: DuoME-PrefixHeader.pch 2.在project——>Bu ...

  2. 我的开源权限管理项目BeCore (基于.net core开发)

    首先 谢谢大家还记得我.. 新年快乐 祝大家工作顺利 事事顺心 人见人爱 车见车载 冬不寒 下雨有伞 全身哪都不疼 就是有人疼 ~~ Github地址:https://github.com/baby8 ...

  3. .NetCore自定义WebAPI返回Json的格式大小写的三种方式

    .NetCore的Controller/WebAPI可以帮我们将返回结果自动转换为Json格式给前台,而且可以自由设定格式(大写.小写.首字母大写等),我总结了三种方法,对应三种灵活度,供大家参考 ( ...

  4. 14、python异常处理及断言

    前言:本文主要介绍python中异常的处理及断言,包括异常类型.异常捕获.主动跑出异常和断言. 一.异常类型介绍 什么是异常?异常即是一个事件,该事件会在程序执行过程中发生,会影响程序的正常执行,一般 ...

  5. 06hive企业调优

    一.Fetch抓取 Fetch抓取是指,Hive 中对某些情况的查询可以不必使用MapReduce计算. 在 hive-default.xml.template 文件中 hive.fetch.task ...

  6. Windows 7原版映像中添加usb3.0驱动

    最近用软碟通制作了一个win7原版映像,但是在装新系统的时候发现了一个问题,进入安装界面后,显示没有找到驱动器,但是明明是差了U盘的,通过“shift+f12”调出命令行窗口,输入disk list命 ...

  7. c/python 的区别

    c             python                                                                                ...

  8. Excel学习——VBA学习(一)

    (一)什么是VBA?什么是宏? VBA (Visual Basic For Application)是一种编程语言,是建立在Office中的一种应用程序开发工具.可以利用VBA有效地扩展Excel的功 ...

  9. .net core3.1 webapi + element-ui upload组件实现文件上传

    首先,先看我个人的的项目结构. 这个webapi项目是专门用来做图片上传,其中分为两个控制器:单图片上传和多图片上传.而我接下来主要讲的还是单文件上传,对于多文件的上传,我暂且尚未研究成功. 其中pi ...

  10. SystemVerilog搭建APB_I2C IP 层次化验证平台

    一.前言 近期疫情严重,身为社畜的我只能在家中继续钻研技术了.之前写过一篇关于搭建FIFO验证平台的博文,利用SV的OOP特性对FIFO进行初步验证,但有很多不足之处,比如结构不够规范.验证组件类不独 ...