input T 1<=T<=10000 n m 1<=n<=2000000007 1<=m<=32 output m个鸡蛋从1到n哪一楼x扔下去刚好没碎,而再x+1楼扔下去就碎了,求最少扔的次数无论x为1到n的哪个数都能确定x 如果x>32,输出Impossible,否则输出x 做法:dp,d(x,y)=d(x,y-1)+d(x-1,y-1),x:egg,y:floor求出下限,即x个鸡蛋至少要试多少次 # include <stdio.h> # in…
这是一道经典的DP模板题. https://vjudge.net/problem/POJ-3783#author=Herlo 一开始也是不知道咋写,尝试找了很多博客,感觉有点领悟之后写下自己的理解. 题意就是: 对于一种蛋,如果它在第m层楼摔不碎,但是在第m+1层摔碎了,那么它的硬度就是m. 有若干层楼,你有若干个一样的蛋,你每一次尝试的结果都会是最坏的情况,问你在这种运气最差的情况下至少丢几次蛋才能知道它的硬度. A. 如果蛋的数量是0,那根本都尝试不了,只能试0次 B. 如果你只有一个蛋,那…
6.5 There is a building of 100 floors. If an egg drops from the Nth floor or above, it will break. If it's dropped from any floor below, it will not break. You're given two eggs. Find N, while minimizing the number of drops for the worst case 这道题说有10…
2014-05-03 22:10 题目链接 原题: Given a dictionary, and a list of letters ( or consider as a string), find the longest word that only uses letters from the string. [I didn't meet this question, what's the best solution?] 题目:给定一个字符串,和一个字典.从字典中找出一个最长的词,并且这个词…
4554 BallsThe classic Two Glass Balls brain-teaser is often posed as:“Given two identical glass spheres, you would like to determine the lowest floor in a 100-storybuilding from which they will break when dropped. Assume the spheres are undamagedwhen…
题目原文: Suppose that you have an n-story building (with floors 1 through n) and plenty of eggs. An egg breaks if it is dropped from floor T or higher and does not break otherwise. Your goal is to devise a strategy to determine the value of T given the…
2014-05-08 23:45 题目链接 原题: How would you use Dijkstra's algorithm to solve travel salesman problem, which is to find a shortest path from a starting node back to the starting node and visits all other node exactly once. 题目:如何用Dijkstra算法来解决TSP问题?(谁会出这种…
2014-05-08 21:33 题目链接 原题: largest number that an int variable can fit given a memory of certain size 题目:给定特定内存大小,请问int型的变量能表示的最大整数是多少? 解法:这个“Guy”出的题目总是这样表意不清.特定大小的内存是什么意思?他要说的是字长吧?16位int占两字节,32位以后int都占四字节.这样能表示的最大整数就是(1 << sizeof(int) * 8 - 1) - 1.…
2014-05-06 10:18 题目链接 原题: Given a ,) (,) (,), (,) should be returned. Some suggest to use Interval Tree to get this done in O(logn), but I did not understand how to construct and use the Interval Tree after reading its wiki page. Is there any other w…
2014-05-06 07:11 题目链接 原题: Find a shortest path ,) to (N,N), assume is destination, use memorization to cache the result. Here is my code. I am not sure if I am caching it right. 题目:给定一个N * N的矩阵,找出从(0, 0)到(n - 1, n - 1)的最短路径.此人在后面还贴上了自己的代码,从代码水平上看此人实力…
2014-05-08 23:18 题目链接 原题: If you have data coming in rapid succession what is the best way of dealing with redundant data? 题目:如果你有大量数据流入,如何处理冗余数据? 解法:又是“Guy”出的题,题意不清,没有情景.神马意思?做个Cache吧. 代码: // http://www.careercup.com/question?id=5680330589601792 //…