All submissions for this problem are available.
Scientists in Japan have genetically modified an incredible apple. Each apple can be used to feed one person for one week. Furthermore, the apple trees will take only one week to grow the fruit. An apple tree will start by producing one apple, then one more apple per week. So a tree when first planted, will produce 1 apple, then 2 apples the following week, 3 apples the week after that, and so forth. It takes 1 apple to grow a new tree, taking a full week to grow and produce the fruit. Thus, given a number of people and a starting apple, how long will it take (in weeks) to produce enough apple trees to sustain the population?
A sample input will simply be read from stdin and contain two integers separated by space - the first number being the number of people N, the second being the starting amount of apples S.
where N, S are integer values such that
N > 0 && N < 2^31
S > 0 && S < 10^5
Your program should display the output to stdout.
Your output will simply be how long (in weeks) it takes for the enough apple trees to start producing enough apples for the population. The corresponding output to the previous input:
Note: There is NO newline character at the end of the output.
Starting with 1 apple, in one week there will be 1 apple produced, in the second week there will be 3 apples produced, in the third week there will be 8 apples produced, and in fourth week there will be 21 apples produced making it sustainable for the population.
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.