#13178. [ICPC 2016 WF] Forever Young

[ICPC 2016 WF] Forever Young

[ICPC 2016 WF] Forever Young

题目描述

My birthday is coming up. Alas, I am getting old and would like to feel young again. Fortunately, I have come up with an excellent way of feeling younger: if I write my age as a number in an appropriately chosen base $b$, then it appears to be smaller. For instance, suppose my age in base $10$ is $32$. Written in base $16$ it is only $20$!

However, I cannot choose an arbitrary base when doing this. If my age written in base bb contains digits other than 00 to 99, then it will be obvious that I am cheating, which defeats the purpose. In addition, if my age written in base bb is too small then it would again be obvious that I am cheating.

Given my age yy and a lower bound ℓ\ell on how small I want my age to appear, find the largest base bb such that yy written in base bb contains only decimal digits, and is at least ℓ\ell when interpreted as a number in base 1010.

输入格式

The input consists of a single line containing two base 10 integers $y$ ($10 \le y \le 10^{18}$ – yes, I am very old) and $\ell $ ($10 \le \ell \le y$).

输出格式

Display the largest base $b$ as described above.
32 20
16
2016 100
42

提示

Time limit: 1000 ms, Memory limit: 1048576 kB.

International Collegiate Programming Contest (ACM-ICPC) World Finals 2016 标签: P6921|2016|ICPC|WF

来源

P6921|[ICPC 2016 WF] Forever Young