結果

問題 No.890 移調の限られた旋法
ユーザー rlangevinrlangevin
提出日時 2023-10-10 12:30:31
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 976 bytes
コンパイル時間 463 ms
コンパイル使用メモリ 87,220 KB
実行使用メモリ 93,112 KB
最終ジャッジ日時 2023-10-10 12:30:38
合計ジャッジ時間 6,895 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
71,740 KB
testcase_01 AC 94 ms
71,664 KB
testcase_02 AC 93 ms
71,848 KB
testcase_03 AC 93 ms
71,464 KB
testcase_04 AC 94 ms
71,892 KB
testcase_05 AC 95 ms
71,464 KB
testcase_06 AC 94 ms
71,500 KB
testcase_07 AC 97 ms
71,764 KB
testcase_08 AC 98 ms
71,660 KB
testcase_09 AC 95 ms
71,784 KB
testcase_10 AC 95 ms
71,476 KB
testcase_11 AC 97 ms
71,860 KB
testcase_12 AC 95 ms
71,996 KB
testcase_13 WA -
testcase_14 AC 123 ms
92,564 KB
testcase_15 AC 128 ms
93,112 KB
testcase_16 AC 127 ms
92,916 KB
testcase_17 AC 131 ms
91,988 KB
testcase_18 AC 127 ms
91,672 KB
testcase_19 AC 115 ms
85,344 KB
testcase_20 AC 111 ms
82,360 KB
testcase_21 AC 106 ms
78,024 KB
testcase_22 AC 119 ms
88,880 KB
testcase_23 AC 122 ms
91,688 KB
testcase_24 AC 123 ms
85,452 KB
testcase_25 AC 109 ms
78,888 KB
testcase_26 AC 126 ms
92,116 KB
testcase_27 AC 124 ms
92,364 KB
testcase_28 AC 117 ms
86,764 KB
testcase_29 AC 115 ms
83,556 KB
testcase_30 AC 127 ms
91,676 KB
testcase_31 AC 121 ms
85,616 KB
testcase_32 AC 131 ms
90,700 KB
testcase_33 AC 127 ms
91,552 KB
testcase_34 AC 126 ms
91,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def div(n):
    i = 1
    SS = set()
    while i * i <= n:
        if n % i == 0:
            SS.add(i)
            SS.add(n//i)
        i += 1
    SS.discard(1)
    return sorted(list(SS), reverse=True)    

N, K = map(int, input().split())
mod = 10 ** 9 + 7
n = N + 5
fact = [1] * (n + 1)
invfact = [1] * (n + 1)
for i in range(1, n):
    fact[i + 1] = ((i+1) * fact[i]) % mod
invfact[n] = pow(fact[n], mod - 2, mod)
for i in range(n - 1, -1, -1):
    invfact[i] = invfact[i + 1] * (i + 1) % mod

def comb(n, r):
    if n < 0 or r < 0 or n - r < 0:
        return 0
    return fact[n] * invfact[r] * invfact[n - r] % mod


from collections import *

D = defaultdict(int)
for d in div(N):
    if K % d:
        continue
    D[N // d] += comb(N // d, K // d)
    D[N // d] %= mod
    for dd in div(N // d):
        if N // d == dd:
            continue
        D[N // d] -= D[dd]
        D[N // d] %= mod

ans = 0
for k, v in D.items():
    ans += v
    ans %= mod

print(ans)
0