結果
| 問題 |
No.1809 Divide NCK
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-01-14 22:46:05 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 57 ms / 2,000 ms |
| コード長 | 526 bytes |
| コンパイル時間 | 171 ms |
| コンパイル使用メモリ | 82,788 KB |
| 実行使用メモリ | 59,868 KB |
| 最終ジャッジ日時 | 2024-11-20 13:10:54 |
| 合計ジャッジ時間 | 3,349 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 39 |
ソースコード
n,k,m = map(int,input().split())
now = m
def count_divs(x,y):
count = 0
now = x
while now <= y:
count += y//now
now *= x
return count
ans = 10**20
for i in range(2,int(m**0.5)+1):
if now%i:
continue
div = 0
while now%i == 0:
now //= i
div += 1
nc = count_divs(i,n)
kc = count_divs(i,k) + count_divs(i,n-k)
ans = min(ans,(nc-kc)//div)
if now != 1:
ans = min(ans,count_divs(now,n)-count_divs(now,k)-count_divs(now,n-k))
print(ans)