| Online MIPT programming contest | РУССКИЙ |
| <PREV Problem: | NEXT> |
< |
|---|
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 < 5000.
Output. One line with M.
See also the problem 093.
Input#12 |
Output#10 |
Input#24 |
Output#23 |
Input#35 |
Output#34 |
Author:
Voroztsov Artem, MIPT contest, February 2003
14 February 2003
© acm.mipt DevGroup The page was generated in 370ms |