uva10934 Dropping water balloons

Source: Internet
Author: User

Long time no title has been no state and then brush a water problem to play

Winter vacation Training and school games have done a similar topic but then did not (in fact, now will not

Test instructions: There are k balloons and an n-storey building, the balloon has a hardness, in some would have just broken, ask at least how many times the experiment can be found just broken floor.

Solution: Divided into two cases: the current floor broken, the current floor is not broken, and then F[i][j] "I" Balloon experiment J can be measured to the highest floor, so f[i][j]=j[i-1][j-1]+f[i][j-1]+1

1#include <cstdio>2#include <iostream>3#include <cmath>4#include <algorithm>5#include <cstring>6#include <cstdlib>7#include <queue>8#include <vector>9#include <map>Ten#include <stack> One#include <string> A  - using namespacestd; -  the Long LongN; - intK; - Long Longf[101][101]; -  + voidsolve () { -     if(f[k][ the]<N) { +printf"More than trials needed.\n"); A             return; at     } -      for(intI=0;i< -; i++){ -             if(f[k][i]>=N) { -printf"%d\n", i); -                      Break; -             } in     } - } to  + intMain () { -Memset (F,0,sizeof(f)); the      for(intI=1; i<= -; i++){ *              for(intj=1;j< -; j + +){ $f[i][j]=f[i-1][j-1]+f[i][j-1]+1;Panax Notoginseng             } -     } the      while(SCANF ("%d%lld", &k,&n) = =2){ +             if(k==0)return 0; A solve (); the     } +     return 0; - } $ /* $ 2 - Ten 786599 - 4 786599 the 1844674407370955161 - 9223372036854775807Wuyi 0 0 the */
View Code

uva10934 Dropping water balloons

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.