#P6921. [ICPC2016 WF] Forever Young
[ICPC2016 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 , 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.
题目大意
题目大意
我的生日快到了!唉,但如今我已经老了,我想重新获得年轻的感觉。
幸运的是,我想出了一个让人感觉更年轻的好方法:如果我把我的年龄以适当选择的进制书写,那么它看起来会更小。例如,假设我以进制书写的年龄是岁;以进制书写,它只有()!
然而,在这样做时,我不能选择任意进制数。如果以进制为数写的我的年龄包含以外的数字,那么很明显我在作弊,这违背了目的。此外,如果我的年龄的进制数太小,那么很明显我在作弊。
在我希望我的年龄看起来有多小的问题上,考虑到我的年龄和下限,找到最大的进制数,这样写在基数中的只包含十进制数字,并且当将其看做一个十进制数字时至少是。
输入格式
输入由一行组成,其中包含两个进制的整数 ( –是的,我很老)和()
输出格式
如上所述,输出最大进制数。
说明/提示
时间限制:,内存限制:
(洛谷这里实际是,但原题是)
国际大学生编程大赛-世界总决赛
32 20
16
2016 100
42
提示
Time limit: 1000 ms, Memory limit: 1048576 kB.
International Collegiate Programming Contest (ACM-ICPC) World Finals 2016