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:||ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.3.2, CPP 6.3, CPP14, CS2, D, ERL, FORT, FS, GO, HASK, ICK, ICON, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYPY, PYTH, PYTH 3.5, RUBY, SCALA, SCM chicken, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC|
Fetching successful submissions
If you are still having problems, see a sample solution here.