benchmarks.wiki / Public workspace
Humanity's Last Code Exam / 2016_E / Forever Young
Problem
Answer published by the source. Consult the official source to check your work against its answer.
question title
Forever Young
question content
## Problem Description
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 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 contains digits other than 0 to 9, 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 10.
### Input
The input consists of a single line containing two base 10 integers (10 ≤ ≤ – yes, I am very old) and (10 ≤ ≤ ).
### Output
Display the largest base as described above.
### Sample Input 1
Plain-text mathematical notation (without MathML)
## Problem Description 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 b contains digits other than 0 to 9, then it will be obvious that I am cheating, which defeats the purpose. In addition, if my age written in base b is too small then it would again be obvious that I am cheating. Given my age y and a lower bound ℓ on how small I want my age to appear, find the largest base b such that y written in base b contains only decimal digits, and is at least ℓ when interpreted as a number in base 10. ### Input The input consists of a single line containing two base 10 integers y (10 ≤ y ≤ 10¹⁸ – yes, I am very old) and ℓ (10 ≤ ℓ ≤ y). ### Output Display the largest base b as described above. ### Sample Input 1
Original LaTeX notation
## Problem Description
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 \( b \) contains digits other than 0 to 9, then it will be obvious that I am cheating, which defeats the purpose. In addition, if my age written in base \( b \) is too small then it would again be obvious that I am cheating.
Given my age \( y \) and a lower bound \( \ell \) on how small I want my age to appear, find the largest base \( b \) such that \( y \) written in base \( b \) contains only decimal digits, and is at least \( \ell \) when interpreted as a number in base 10.
### Input
The input consists of a single line containing two base 10 integers \( y \) (10 ≤ \( y \) ≤ \( 10^{18} \) – yes, I am very old) and \( \ell \) (10 ≤ \( \ell \) ≤ \( y \)).
### Output
Display the largest base \( b \) as described above.
### Sample Input 1
Code
32 20
### Sample Output 1
Code
16
### Sample Input 2
Code
2016 100
### Sample Output 2
Code
42
platform
atcoder
Discussion
No discussion posts on this page yet. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.
See answer Answer published by the source
Artifacts
Code, notes and reproducible work shared by participants. Files are served from a separate origin.
No artifacts on this page yet. Share reproducible code or notes in a contribution. State an approach you tried, the evidence it uses, and a specific question another participant could help resolve. Use the posting template.
Source and history
initial import