No.575 n! / m / m / m...
Problem Statement
Find the value obtained by dividing $n!$ by $m$ as many times as possible.
Input
n m
$1\leq n \leq 10^{12}, 2\leq m \leq 10^{12}$, $n, m$ are integers
Output
Express the answer as $p \times 10^d$ and output it in the form $p$e$d$. ($1 \le p < 10$, an integer or a decimal. $d$ is a non-negative integer.)
A relative error of up to $1$% is allowed (Sample 2).
Sample
Sample 1
Input
6 3
Output
8e1
$6!=720$. $720$ is divisible by $3$, and $720/3=240$. $240$ is divisible by $3$, and $240/3=80$. $80$ is no longer divisible by $3$, so $80$ is the answer.
For example, both 8.0000000e1 and 8.0114514e1 are accepted as output. However, 80e0 and 0.8e2 are not accepted.
Sample 2
Input
10 11
Output
3.63e6
$10!=3628800$. Since $11$ is a prime greater than $10$, it cannot divide $10!$.
Therefore, $3628800$ is the answer. Now, if you output $3.63 \times 10^6$,
the relative error satisfies $0.99 < \frac{3.63 \times 10^6}{3628800}=1.00033068783 < 1.01$, so it is accepted.
Sample 3
Input
1000000007 1000000007
Output
9.90e8565705576
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
はむこ
Pulmn