|Online MIPT programming contest||РУССКИЙ|
Time limit = 5 second(s)Pete thinks out a rational number (irreducible fraction) x, 0 < x < 1, with denominator less or equal to N.
You may ask him questions like
"Is it true that x < r?"
for any number r.
Please, write program that determines minimal number M(N) of questions that will be sufficient to guess the number. It meens that there exists an algorithm of asking questions such that after M or less questions it leads to unambiguity about x.
Input. One line with N, 1 < N < 2000000.
Output. One line with M.
Voroztsov Artem, MIPT contest, February 2003
14 February 2003
© acm.mipt DevGroup
The page was generated in 190ms