結果

問題 No.890 移調の限られた旋法
ユーザー SalmonizeSalmonize
提出日時 2020-05-04 19:58:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 166 ms / 2,000 ms
コード長 664 bytes
コンパイル時間 545 ms
コンパイル使用メモリ 87,104 KB
実行使用メモリ 107,948 KB
最終ジャッジ日時 2023-09-07 03:07:50
合計ジャッジ時間 6,578 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
91,548 KB
testcase_01 AC 94 ms
91,676 KB
testcase_02 AC 91 ms
91,512 KB
testcase_03 AC 91 ms
91,596 KB
testcase_04 AC 93 ms
91,840 KB
testcase_05 AC 92 ms
91,696 KB
testcase_06 AC 90 ms
91,576 KB
testcase_07 AC 94 ms
91,660 KB
testcase_08 AC 93 ms
91,568 KB
testcase_09 AC 89 ms
91,668 KB
testcase_10 AC 94 ms
91,576 KB
testcase_11 AC 92 ms
91,588 KB
testcase_12 AC 92 ms
91,500 KB
testcase_13 AC 162 ms
107,856 KB
testcase_14 AC 158 ms
107,920 KB
testcase_15 AC 147 ms
107,816 KB
testcase_16 AC 155 ms
107,948 KB
testcase_17 AC 155 ms
106,320 KB
testcase_18 AC 149 ms
106,392 KB
testcase_19 AC 135 ms
100,460 KB
testcase_20 AC 124 ms
97,360 KB
testcase_21 AC 106 ms
93,308 KB
testcase_22 AC 145 ms
104,296 KB
testcase_23 AC 160 ms
106,764 KB
testcase_24 AC 135 ms
100,620 KB
testcase_25 AC 112 ms
94,048 KB
testcase_26 AC 147 ms
107,184 KB
testcase_27 AC 166 ms
107,468 KB
testcase_28 AC 141 ms
101,992 KB
testcase_29 AC 125 ms
98,648 KB
testcase_30 AC 159 ms
106,476 KB
testcase_31 AC 135 ms
100,340 KB
testcase_32 AC 151 ms
105,296 KB
testcase_33 AC 156 ms
106,060 KB
testcase_34 AC 150 ms
105,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n_ = 10**6
mod = 10**9 + 7
fun = [1] * (n_ + 1)
for i in range(1, n_ + 1):
    fun[i] = fun[i - 1] * i % mod
rev = [1] * (n_ + 1)
rev[n_] = pow(fun[n_], mod - 2, mod)
for i in range(n_ - 1, 0, -1):
    rev[i] = rev[i + 1] * (i + 1) % mod

def nCr(n, r):
    if r > n:
        return 0
    return fun[n] * rev[r] % mod * rev[n - r] % mod
    
n, k = map(int, input().split())
res = [0]*(n+1)
sieve = [1]*(n+1)
for x in range(2,k+1):
    if n % x == k % x == 0:
        res[x] = nCr(n//x, k//x)
for p in range(2, n+1):
    if sieve[p]:
        for i in range(2, n//p+1):
            sieve[i*p] = 0
            res[i] = (res[i] - res[i*p]) % mod
print(sum(res) % mod)
0