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