SOMPO HD プログラミングコンテスト2021(AtCoder Beginner Contest 192)
翻译中…
Problem Statement
翻译中…
Given are a string $X$ consisting of 0 through 9, and an integer $M$.
翻译中…
Let $d$ be the greatest digit in $X$.
翻译中…
How many different integers not greater than $M$ can be obtained by choosing an integer $n$ not less than $d+1$ and seeing $X$ as a base-$n$ number?
翻译中…
Constraints
翻译中…
$X$consists of0through9.- The length of
$X$is between$1$and$60$(inclusive). $X$does not begin with a0.$1 \leq M \leq 10^{18}$
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
X
M
翻译中…
Output
翻译中…
Print the answer.
翻译中…
样例
Input #1
22
10
Output #1
2
The greatest digit in $X$ is `2`.
- By seeing $X$ as a base-$3$ number, we get $8$.
- By seeing $X$ as a base-$4$ number, we get $10$.
These two values are the only ones that we can obtain and are not greater than $10$.
Input #2
999
1500
Output #2
3
The greatest digit in $X$ is `9`.
- By seeing $X$ as a base-$10$ number, we get $999$.
- By seeing $X$ as a base-$11$ number, we get $1197$.
- By seeing $X$ as a base-$12$ number, we get $1413$.
These three values are the only ones that we can obtain and are not greater than $1500$.
Input #3
100000000000000000000000000000000000000000000000000000000000
1000000000000000000
Output #3
1
By seeing $X$ as a base-$2$ number, we get $576460752303423488$, which is the only value that we can obtain and are not greater than $1000000000000000000$.
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。