結果

問題 No.1809 Divide NCK
ユーザー SidewaysOwlSidewaysOwl
提出日時 2022-01-14 22:19:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 97 ms / 2,000 ms
コード長 829 bytes
コンパイル時間 210 ms
コンパイル使用メモリ 82,980 KB
実行使用メモリ 62,264 KB
最終ジャッジ日時 2024-04-30 15:29:45
合計ジャッジ時間 3,437 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
55,776 KB
testcase_01 AC 42 ms
53,948 KB
testcase_02 AC 42 ms
55,568 KB
testcase_03 AC 42 ms
54,800 KB
testcase_04 AC 44 ms
54,764 KB
testcase_05 AC 43 ms
55,944 KB
testcase_06 AC 43 ms
54,732 KB
testcase_07 AC 43 ms
54,392 KB
testcase_08 AC 45 ms
54,856 KB
testcase_09 AC 43 ms
54,264 KB
testcase_10 AC 42 ms
53,944 KB
testcase_11 AC 43 ms
54,580 KB
testcase_12 AC 42 ms
54,692 KB
testcase_13 AC 49 ms
61,448 KB
testcase_14 AC 43 ms
55,196 KB
testcase_15 AC 44 ms
54,796 KB
testcase_16 AC 96 ms
62,264 KB
testcase_17 AC 49 ms
61,264 KB
testcase_18 AC 93 ms
61,508 KB
testcase_19 AC 97 ms
60,952 KB
testcase_20 AC 47 ms
61,360 KB
testcase_21 AC 44 ms
55,616 KB
testcase_22 AC 42 ms
54,460 KB
testcase_23 AC 42 ms
54,716 KB
testcase_24 AC 42 ms
55,536 KB
testcase_25 AC 43 ms
54,720 KB
testcase_26 AC 42 ms
54,716 KB
testcase_27 AC 43 ms
54,916 KB
testcase_28 AC 43 ms
54,268 KB
testcase_29 AC 74 ms
60,580 KB
testcase_30 AC 47 ms
61,352 KB
testcase_31 AC 47 ms
60,428 KB
testcase_32 AC 43 ms
55,132 KB
testcase_33 AC 53 ms
61,320 KB
testcase_34 AC 47 ms
62,244 KB
testcase_35 AC 48 ms
60,540 KB
testcase_36 AC 47 ms
62,096 KB
testcase_37 AC 44 ms
54,716 KB
testcase_38 AC 44 ms
55,680 KB
testcase_39 AC 43 ms
54,396 KB
testcase_40 AC 44 ms
54,992 KB
testcase_41 AC 44 ms
54,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,k,m = map(int,input().split())
def prime_factorization(w,d):
    cnt = 2
    while w > 1:
        if cnt > int(w ** (1/2)):
            d[w] += 1
            break
        while w % cnt == 0:
            d[cnt] += 1
            w //= cnt
        cnt += 1
from collections import defaultdict
m_d = defaultdict(int)
prime_factorization(m,m_d)
def f_prime(N,K):
    d = defaultdict(int)
    def cul(nn,pm):
        for key in m_d.keys():
            cnt = 1
            while key ** cnt <= nn:
                if pm :
                    d[key] += nn // (key ** cnt)
                else:
                    d[key] -= nn // (key ** cnt)
                cnt += 1
    cul(N,True)
    cul(N-K,False)
    cul(K,False)
    return d
n_d = f_prime(n,k)
ans = 10000
for key in m_d.keys():
    ans = min(ans,n_d[key]//m_d[key])
print(ans)
0