Uva31634 dropping water balloons DP

Source: Internet
Author: User

Dropping water balloons
Time limit:3000 Ms   Memory limit:Unknown   64bit Io format:% LLD & % LlU

[Submit]
[Go Back] [Status]

Description


Problem A: dropping water balloons

It's frosh week, and this year your friends have decided that they wocould initiate the new computer science students by dropping water balloons on them. they 've filled up a large crate of identical water balloons, ready for the event. but as fate wowould have
It, the balloons turned out to be rather tough, and can be dropped from a height of several stories without bursting!

So your friends have sought you out for help. they plan to drop the balloons from a tall building on campus, but wocould like to spend as little effort as possible hauling their balloons up the stairs, so they
Wocould like to know the lowest floor from which they can drop the balloons so that they do burst.

You know the building has n floors, and your friends have given you K identical balloons which you may use (and break) during your trials to find their answer. since you are also lazy, you
wocould like to determine the minimum number of trials you must conducting in order to determine with absolute certainty the lowest floor from which you can drop a balloon so that it bursts (or in the worst case, that the balloons will not burst even when dropped
from the top floor ). A trial consists of dropping a balloon from a certain floor. if a balloon fails to burst for a trial, you can fetch it and use it again for another trial.

The input consists of a number of test cases, one case per line. The data for one test case consists of two numbersKAndN, 1 ≤K≤ 100 and a positiveNThat fits into a 64 bit
INTEGER (yes, it'sVeryTall Building). The last case hasK= 0 and shoshould not be processed.

For each case of the input, print one line of output giving the minimum number of trials needed to solve the problem. If more than 63 trials are needed then printMore than 63 trials needed.Instead
Of the number.

Sample Input
 
2 10010 7865994 78659960 184467440737095516163 92233720368547758070 0
Output for sample input
1421 more than 63 trials needed.6163
Piotr rudnicki

 
# Include <iostream> # include <cstring> # include <cstdio> # include <string> using namespace STD; typedef unsigned long ll; int K; ll N, f [110] [110]; int main () {for (INT I = 0; I <= 65; I ++) f [0] [I] = 0; for (INT I = 1; I <= 65; I ++) {f [I] [0] = 0; For (Int J = 1; j <= 65; j ++) f [I] [J] = f [I-1] [J-1] + F [I-1] [J] + 1 ;} while (CIN> K> N & K> 0) {int cur = 0, ANS = 0; If (k> 63) k = 63; int m, L = 0, r = 64; while (L <r) {M = (L + r)/2; If (F [m] [k]> = N) R = m; else l = m + 1;} If (r <= 63) cout <r <Endl; else cout <"more than 63 trials needed. "<Endl;} return 0 ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.