結果

問題 No.1809 Divide NCK
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2022-01-14 21:40:16
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 410 bytes
コンパイル時間 165 ms
コンパイル使用メモリ 82,464 KB
実行使用メモリ 59,844 KB
最終ジャッジ日時 2024-04-30 13:34:20
合計ジャッジ時間 3,288 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
59,640 KB
testcase_01 AC 48 ms
57,672 KB
testcase_02 AC 51 ms
58,432 KB
testcase_03 AC 48 ms
57,840 KB
testcase_04 WA -
testcase_05 AC 54 ms
59,580 KB
testcase_06 AC 54 ms
58,724 KB
testcase_07 WA -
testcase_08 AC 52 ms
59,088 KB
testcase_09 AC 56 ms
58,984 KB
testcase_10 AC 51 ms
58,872 KB
testcase_11 AC 54 ms
59,104 KB
testcase_12 AC 55 ms
58,328 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 49 ms
57,680 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 49 ms
58,904 KB
testcase_22 AC 49 ms
57,312 KB
testcase_23 AC 49 ms
58,056 KB
testcase_24 AC 49 ms
58,072 KB
testcase_25 AC 49 ms
58,832 KB
testcase_26 AC 48 ms
59,156 KB
testcase_27 AC 49 ms
58,656 KB
testcase_28 WA -
testcase_29 AC 49 ms
58,484 KB
testcase_30 WA -
testcase_31 AC 48 ms
58,980 KB
testcase_32 AC 50 ms
57,948 KB
testcase_33 AC 51 ms
58,000 KB
testcase_34 WA -
testcase_35 AC 49 ms
58,400 KB
testcase_36 WA -
testcase_37 AC 51 ms
58,572 KB
testcase_38 AC 52 ms
58,132 KB
testcase_39 AC 49 ms
58,164 KB
testcase_40 AC 49 ms
58,044 KB
testcase_41 AC 49 ms
59,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def cont(x,M):

    ret = 0
    div = M
    while x >= div:
        ret += x // div
        div *= M
    return ret

N,K,M = map(int,input().split())

q = set()
for i in range(2,10**6+1):

    if M % i == 0:
        q.add(i)
        while M % i == 0:
            M //= i
if M != 1:
    q.add(i)


ans = float("inf")
for mod in q:

    ans =  min( ans , cont(N,mod) - cont(K,mod) - cont(N-K,mod) )
print (ans)
0