結果

問題 No.890 移調の限られた旋法
ユーザー SalmonizeSalmonize
提出日時 2020-05-04 19:29:41
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 667 bytes
コンパイル時間 440 ms
コンパイル使用メモリ 86,944 KB
実行使用メモリ 107,916 KB
最終ジャッジ日時 2023-09-07 02:35:43
合計ジャッジ時間 6,961 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
91,756 KB
testcase_01 AC 98 ms
91,528 KB
testcase_02 AC 98 ms
91,696 KB
testcase_03 AC 94 ms
91,508 KB
testcase_04 AC 97 ms
91,664 KB
testcase_05 AC 98 ms
91,784 KB
testcase_06 AC 98 ms
91,488 KB
testcase_07 AC 98 ms
91,664 KB
testcase_08 AC 98 ms
91,544 KB
testcase_09 AC 96 ms
91,816 KB
testcase_10 AC 97 ms
91,676 KB
testcase_11 AC 96 ms
91,468 KB
testcase_12 AC 97 ms
91,436 KB
testcase_13 WA -
testcase_14 AC 169 ms
107,776 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 132 ms
97,644 KB
testcase_21 AC 111 ms
93,364 KB
testcase_22 AC 159 ms
104,200 KB
testcase_23 AC 183 ms
107,008 KB
testcase_24 AC 145 ms
100,732 KB
testcase_25 AC 115 ms
94,100 KB
testcase_26 WA -
testcase_27 AC 194 ms
107,296 KB
testcase_28 AC 154 ms
102,016 KB
testcase_29 AC 133 ms
98,564 KB
testcase_30 AC 189 ms
106,368 KB
testcase_31 AC 144 ms
100,252 KB
testcase_32 WA -
testcase_33 AC 180 ms
105,964 KB
testcase_34 AC 175 ms
106,160 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(n//p, 1, -1):
            sieve[i*p] = 0
            res[i] = (res[i] - res[i*p]) % mod
print(sum(res) % mod)
0