結果

問題 No.890 移調の限られた旋法
ユーザー SalmonizeSalmonize
提出日時 2020-05-04 19:27:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 667 bytes
コンパイル時間 340 ms
コンパイル使用メモリ 10,900 KB
実行使用メモリ 102,180 KB
最終ジャッジ日時 2023-09-07 02:34:01
合計ジャッジ時間 53,440 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 705 ms
86,196 KB
testcase_01 AC 702 ms
86,468 KB
testcase_02 AC 700 ms
86,164 KB
testcase_03 AC 698 ms
86,380 KB
testcase_04 AC 713 ms
86,244 KB
testcase_05 AC 700 ms
86,208 KB
testcase_06 AC 708 ms
86,192 KB
testcase_07 AC 696 ms
86,192 KB
testcase_08 AC 703 ms
86,292 KB
testcase_09 AC 707 ms
86,132 KB
testcase_10 AC 708 ms
86,388 KB
testcase_11 AC 702 ms
86,336 KB
testcase_12 AC 696 ms
86,384 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 TLE -
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 WA -
testcase_20 AC 1,223 ms
91,824 KB
testcase_21 AC 795 ms
87,592 KB
testcase_22 AC 1,900 ms
98,356 KB
testcase_23 TLE -
testcase_24 AC 1,548 ms
94,992 KB
testcase_25 AC 876 ms
88,376 KB
testcase_26 TLE -
testcase_27 TLE -
testcase_28 AC 1,705 ms
96,236 KB
testcase_29 AC 1,333 ms
92,880 KB
testcase_30 TLE -
testcase_31 AC 1,494 ms
94,300 KB
testcase_32 TLE -
testcase_33 TLE -
testcase_34 TLE -
権限があれば一括ダウンロードができます

ソースコード

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