結果

問題 No.890 移調の限られた旋法
ユーザー rlangevinrlangevin
提出日時 2023-10-10 12:37:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 947 bytes
コンパイル時間 420 ms
コンパイル使用メモリ 87,336 KB
実行使用メモリ 92,844 KB
最終ジャッジ日時 2023-10-10 12:37:50
合計ジャッジ時間 5,989 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
71,584 KB
testcase_01 AC 94 ms
71,820 KB
testcase_02 AC 96 ms
71,808 KB
testcase_03 AC 95 ms
71,756 KB
testcase_04 AC 95 ms
71,808 KB
testcase_05 AC 93 ms
71,676 KB
testcase_06 AC 92 ms
71,628 KB
testcase_07 AC 93 ms
71,668 KB
testcase_08 AC 91 ms
71,624 KB
testcase_09 AC 96 ms
71,712 KB
testcase_10 AC 95 ms
71,620 KB
testcase_11 AC 92 ms
71,724 KB
testcase_12 AC 90 ms
71,804 KB
testcase_13 AC 121 ms
92,844 KB
testcase_14 AC 121 ms
92,344 KB
testcase_15 AC 120 ms
92,776 KB
testcase_16 AC 123 ms
92,532 KB
testcase_17 AC 118 ms
91,016 KB
testcase_18 AC 125 ms
91,360 KB
testcase_19 AC 109 ms
85,320 KB
testcase_20 AC 108 ms
82,200 KB
testcase_21 AC 101 ms
78,056 KB
testcase_22 AC 115 ms
89,052 KB
testcase_23 AC 117 ms
91,560 KB
testcase_24 AC 112 ms
85,408 KB
testcase_25 AC 104 ms
78,812 KB
testcase_26 AC 120 ms
92,000 KB
testcase_27 AC 124 ms
92,428 KB
testcase_28 AC 112 ms
86,912 KB
testcase_29 AC 108 ms
83,176 KB
testcase_30 AC 120 ms
91,532 KB
testcase_31 AC 115 ms
85,232 KB
testcase_32 AC 125 ms
90,496 KB
testcase_33 AC 124 ms
91,384 KB
testcase_34 AC 125 ms
91,016 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[d] += comb(N // d, K // d)
    D[d] %= mod
    for dd in div(d):
        if d == dd:
            continue
        D[dd] -= D[d]
        D[dd] %= mod

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

print(ans)
0