結果

問題 No.1809 Divide NCK
ユーザー horitaka1999horitaka1999
提出日時 2022-01-15 12:21:50
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,077 bytes
コンパイル時間 1,081 ms
コンパイル使用メモリ 86,672 KB
実行使用メモリ 76,944 KB
最終ジャッジ日時 2023-08-13 16:03:46
合計ジャッジ時間 7,947 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
71,744 KB
testcase_01 AC 94 ms
71,792 KB
testcase_02 AC 93 ms
71,828 KB
testcase_03 AC 95 ms
71,708 KB
testcase_04 AC 93 ms
71,824 KB
testcase_05 AC 94 ms
71,452 KB
testcase_06 AC 93 ms
71,620 KB
testcase_07 AC 93 ms
71,696 KB
testcase_08 AC 93 ms
71,800 KB
testcase_09 AC 94 ms
71,788 KB
testcase_10 AC 92 ms
71,732 KB
testcase_11 AC 93 ms
71,820 KB
testcase_12 AC 94 ms
71,708 KB
testcase_13 AC 98 ms
76,864 KB
testcase_14 AC 95 ms
71,900 KB
testcase_15 AC 99 ms
76,816 KB
testcase_16 AC 116 ms
76,808 KB
testcase_17 AC 100 ms
76,944 KB
testcase_18 AC 114 ms
76,524 KB
testcase_19 AC 112 ms
76,668 KB
testcase_20 AC 99 ms
76,468 KB
testcase_21 AC 94 ms
71,888 KB
testcase_22 AC 96 ms
71,520 KB
testcase_23 AC 96 ms
71,724 KB
testcase_24 AC 97 ms
71,868 KB
testcase_25 AC 96 ms
71,812 KB
testcase_26 AC 94 ms
71,756 KB
testcase_27 AC 94 ms
71,928 KB
testcase_28 WA -
testcase_29 AC 107 ms
76,800 KB
testcase_30 AC 99 ms
76,892 KB
testcase_31 AC 99 ms
76,436 KB
testcase_32 AC 96 ms
71,892 KB
testcase_33 AC 100 ms
76,252 KB
testcase_34 AC 98 ms
76,488 KB
testcase_35 WA -
testcase_36 AC 98 ms
76,480 KB
testcase_37 AC 95 ms
71,760 KB
testcase_38 AC 93 ms
71,804 KB
testcase_39 AC 94 ms
71,788 KB
testcase_40 WA -
testcase_41 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
N,K,M = map(int,input().split())
class get_prime():#使うたびにクラスの定義が必要。self.revの使い回しNG
    def __init__(self):
        self.rev = []
    def prime(self,n):
        if n == 1:
            return self.rev
        for i in range(2,int(n**0.5)+1):
            if n % i == 0:
                self.rev.append(i)
                self.prime(int(n/i))
                break
        else:
            self.rev.append(n)
        return self.rev
gp = get_prime()
mp = gp.prime(M)
pdic = defaultdict(int)
for p in mp:
    pdic[p] += 1

def f(l,r,x,p):
    al = (l + pow(p,x) -1) // pow(p,x)
    al = max(al,1)
    ar = r //pow(p,x)
    if ar >= 1 and al <= ar:
        return ar - al + 1
    else:
        return 0
def g(l,r,p):
    x = 1
    res = 0
    while pow(p,x) <= r:
        res += f(l,r,x,p)
        x += 1
    return res
INF = float('inf')
UP = INF
DOWN = INF
for p in pdic.keys():
    up = g(N-K+1,N,p)//pdic[p]
    down = g(1,K,p) //pdic[p]
    UP = min(UP,up)
    DOWN = min(down,down)
print(UP - DOWN)

0