logo AlgoBeat OnlineJudge
登录 注册

#206067. [ICPC 2016 WF] Forever Young

内存限制:1024 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

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 , then it appears to be smaller. For instance, suppose my age in base is . Written in base it is only !

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

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

输入格式

The input consists of a single line containing two base 10 integers ( – yes, I am very old) and ().

输出格式

Display the largest base as described above.

样例

样例输入 1

32 20

样例输出 1

16

样例输入 2

2016 100

样例输出 2

42

数据范围与提示

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

International Collegiate Programming Contest (ACM-ICPC) World Finals 2016