結果

問題 No.1809 Divide NCK
ユーザー titiatitia
提出日時 2022-01-14 22:04:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 198 ms / 2,000 ms
コード長 509 bytes
コンパイル時間 73 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-04-30 14:51:54
合計ジャッジ時間 4,458 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,752 KB
testcase_01 AC 159 ms
10,752 KB
testcase_02 AC 30 ms
10,752 KB
testcase_03 AC 30 ms
10,752 KB
testcase_04 AC 28 ms
10,880 KB
testcase_05 AC 27 ms
10,752 KB
testcase_06 AC 25 ms
10,752 KB
testcase_07 AC 25 ms
10,880 KB
testcase_08 AC 27 ms
10,752 KB
testcase_09 AC 27 ms
10,752 KB
testcase_10 AC 26 ms
10,880 KB
testcase_11 AC 124 ms
10,880 KB
testcase_12 AC 144 ms
10,880 KB
testcase_13 AC 52 ms
10,752 KB
testcase_14 AC 68 ms
10,752 KB
testcase_15 AC 34 ms
10,752 KB
testcase_16 AC 182 ms
10,880 KB
testcase_17 AC 31 ms
10,752 KB
testcase_18 AC 177 ms
10,880 KB
testcase_19 AC 198 ms
10,880 KB
testcase_20 AC 153 ms
10,752 KB
testcase_21 AC 111 ms
10,880 KB
testcase_22 AC 27 ms
10,880 KB
testcase_23 AC 25 ms
10,880 KB
testcase_24 AC 26 ms
10,880 KB
testcase_25 AC 25 ms
10,752 KB
testcase_26 AC 26 ms
10,752 KB
testcase_27 AC 26 ms
10,880 KB
testcase_28 AC 25 ms
10,752 KB
testcase_29 AC 150 ms
10,880 KB
testcase_30 AC 149 ms
10,752 KB
testcase_31 AC 44 ms
10,880 KB
testcase_32 AC 97 ms
10,752 KB
testcase_33 AC 104 ms
10,752 KB
testcase_34 AC 123 ms
10,752 KB
testcase_35 AC 113 ms
10,752 KB
testcase_36 AC 88 ms
10,752 KB
testcase_37 AC 134 ms
10,880 KB
testcase_38 AC 90 ms
10,752 KB
testcase_39 AC 141 ms
10,752 KB
testcase_40 AC 133 ms
10,752 KB
testcase_41 AC 98 ms
11,008 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

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


x=M
# 素因数分解
import math 
L=int(math.sqrt(x))

FACT=dict()

for i in range(2,L+2):
    while x%i==0:
        FACT[i]=FACT.get(i,0)+1
        x=x//i

if x!=1:
    FACT[x]=FACT.get(x,0)+1

LANS=1<<65

for f in FACT:
    ANS=0

    for i in range(1,65):
        if pow(f,i)>10**18:
            break
        ANS+=N//pow(f,i)

        ANS-=K//pow(f,i)
        ANS-=(N-K)//pow(f,i)

    LANS=min(LANS,ANS//FACT[f])

print(LANS)
    
0