結果

問題 No.1809 Divide NCK
ユーザー SidewaysOwlSidewaysOwl
提出日時 2022-01-14 22:19:06
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 179 ms / 2,000 ms
コード長 829 bytes
コンパイル時間 1,014 ms
コンパイル使用メモリ 86,940 KB
実行使用メモリ 77,448 KB
最終ジャッジ日時 2023-08-12 20:24:19
合計ジャッジ時間 6,283 ms
ジャッジサーバーID
(参考情報)
judge7 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
72,000 KB
testcase_01 AC 86 ms
72,108 KB
testcase_02 AC 85 ms
71,944 KB
testcase_03 AC 92 ms
72,064 KB
testcase_04 AC 90 ms
72,112 KB
testcase_05 AC 88 ms
71,744 KB
testcase_06 AC 86 ms
71,896 KB
testcase_07 AC 92 ms
72,060 KB
testcase_08 AC 86 ms
71,872 KB
testcase_09 AC 89 ms
71,888 KB
testcase_10 AC 90 ms
72,140 KB
testcase_11 AC 87 ms
71,868 KB
testcase_12 AC 86 ms
72,008 KB
testcase_13 AC 117 ms
77,040 KB
testcase_14 AC 91 ms
71,948 KB
testcase_15 AC 94 ms
72,088 KB
testcase_16 AC 176 ms
77,332 KB
testcase_17 AC 95 ms
77,356 KB
testcase_18 AC 172 ms
77,236 KB
testcase_19 AC 179 ms
76,864 KB
testcase_20 AC 96 ms
77,296 KB
testcase_21 AC 89 ms
72,116 KB
testcase_22 AC 86 ms
71,568 KB
testcase_23 AC 85 ms
71,912 KB
testcase_24 AC 88 ms
72,084 KB
testcase_25 AC 85 ms
71,724 KB
testcase_26 AC 85 ms
72,008 KB
testcase_27 AC 84 ms
72,084 KB
testcase_28 AC 88 ms
71,944 KB
testcase_29 AC 137 ms
77,224 KB
testcase_30 AC 96 ms
77,180 KB
testcase_31 AC 93 ms
77,256 KB
testcase_32 AC 86 ms
71,720 KB
testcase_33 AC 96 ms
76,872 KB
testcase_34 AC 90 ms
76,868 KB
testcase_35 AC 93 ms
77,292 KB
testcase_36 AC 92 ms
77,448 KB
testcase_37 AC 84 ms
72,064 KB
testcase_38 AC 85 ms
71,812 KB
testcase_39 AC 87 ms
72,020 KB
testcase_40 AC 86 ms
71,720 KB
testcase_41 AC 85 ms
71,896 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