問題一覧 > 通常問題

No.575 n! / m / m / m...

レベル : / AI推定難易度 : 1625 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / スペシャルジャッジ問題 (複数の解が存在する可能性があります)
タグ : (AC するまで非表示) / 解いたユーザー数 44
作問者 : はむこ / テスター : Pulmn
お気に入りにしたユーザー ProblemId : 1696 / 自分の提出
問題文最終更新日: 2026-06-26 14:12:08
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 174 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。