本文主要是介绍TOJ 3761 Egg Problem,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Egg Problem
描述
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
http://blog.163.com/moon_goddess_2003/blog/static/225157172201310964315742/
这篇关于TOJ 3761 Egg Problem的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!