3 人解决,4 人已尝试。
3 份提交通过,共有 80 份提交。
8.4 EMB 奖励。
单点时限: 4.0 sec
内存限制: 256 MB
For every positive integer we may obtain a non-negative integer by multiplying its digits. This defines a function $f$, e.g. $f(38) = 24$.
This function gets more interesting if we allow for other bases. In base $3$, the number $80$ is written as $2222$, so: $f_3(80) = 16$.
We want you to solve the reverse problem: given a base $B$ and a number $N$, what is the smallest positive integer $X$ such that $f_B(X) = N$?
The input consists of a single line containing two integers $B$ and $N$, satisfying $2 < B \leq 10~000$ and $0 < N < 2^{63}$.
Output the smallest positive integer solution $X$ of the equation $f_B(X) = N$. If no such $X$ exists, output the word impossible
. The input is carefully chosen such that $X < 2^{63}$ holds (if $X$ exists).
10 24
38
9 216
546
10 11
impossible
10000 5810859769934419200
5989840988999909996
3 人解决,4 人已尝试。
3 份提交通过,共有 80 份提交。
8.4 EMB 奖励。
创建: 7 年,1 月前.
修改: 7 年,1 月前.
最后提交: 3 年,12 月前.