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. __call__ 方法

    对象() 或 类()() 调用 __call__里面的方法 class Call: def __call__(self, *args, **kwargs): print("Hello __c ...

  2. Java电商支付系统手把手实现(二) - 数据库表设计的最佳实践

    1 数据库设计 1.1 表关系梳理 仔细思考业务关系,得到如下表关系图 1.2 用户表结构 1.3 分类表结构 id=0为根节点,分类其实是树状结构 1.4 商品表结构 注意价格字段的类型为 deci ...

  3. [bzoj4447] [loj#2010] [Scoi2015] 小凸解密码

    Description 小凸得到了一个密码盘,密码盘被等分成 \(N\) 个扇形,每个扇形上有一个数字(0-9),和一个符号("+"或"*") 密码盘解密的方法 ...

  4. 【javaScript】加减乘除的精确计算

    在js中使用"+"."-"等符号进行运算会出现很大的误差,所以需要自己创建函数进行精确运算. //说明:javascript的加法结果会有误差,在两个浮点数相加 ...

  5. 提供程序模式 提供 coding 一点点

    放个图先,预则立码

  6. python实例:自动爬取豆瓣读书短评,分析短评内容

    思路: 1.打开书本“更多”短评,复制链接 2.脚本分析链接,通过获取短评数,计算出页码数 3.通过页码数,循环爬取当页短评 4.短评写入到txt文本 5.读取txt文本,处理文本,输出出现频率最高的 ...

  7. [总结]ACM模拟总结

    1.心态一定要稳,千万不要慌. 2.内部交流要多点,说不定就讨论出有用的性质了. 3.题目细节一定要想清楚. 4.一道题绝对不能让多个人来写. 5.英语要好好学.

  8. 设计模式-03工厂方法模式(Factory Method Pattern)

    插曲.简单工厂模式(Simple Factory Pattern) 介绍工厂方法模式之前,先来做一个铺垫,了解一下简单工厂模式,它不属于 GoF 的 23 种经典设计模式,它的缺点是增加新产品时会违背 ...

  9. Mesh R-CNN 论文翻译(原理部分)

    毕设做Mesh R-CNN的实现,在此翻译一下原论文.原论文https://arxiv.org/pdf/1906.02739.pdf. 摘要 二维感知的快速发展使得系统能够准确地检测真实世界图像中的物 ...

  10. Jenkins环境配置(集成自动化程序)

    一.下载 直接到官网https://jenkins.io/download/  进行下载 二.安装 1.在浏览器地址栏输入:http://loclhost:8081 运行Jenkins,首次进入会提示 ...