結果

問題 No.890 移調の限られた旋法
ユーザー tjaketjake
提出日時 2019-09-20 22:32:05
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 776 bytes
コンパイル時間 1,669 ms
コンパイル使用メモリ 86,600 KB
実行使用メモリ 99,696 KB
最終ジャッジ日時 2023-10-12 20:05:27
合計ジャッジ時間 5,150 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,380 KB
testcase_01 AC 74 ms
71,612 KB
testcase_02 AC 72 ms
71,516 KB
testcase_03 AC 71 ms
71,436 KB
testcase_04 AC 74 ms
71,520 KB
testcase_05 AC 72 ms
71,356 KB
testcase_06 AC 71 ms
71,564 KB
testcase_07 AC 72 ms
71,472 KB
testcase_08 AC 71 ms
71,316 KB
testcase_09 AC 71 ms
71,376 KB
testcase_10 AC 72 ms
71,480 KB
testcase_11 AC 73 ms
71,236 KB
testcase_12 AC 72 ms
71,428 KB
testcase_13 AC 116 ms
99,600 KB
testcase_14 AC 120 ms
99,440 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 114 ms
97,084 KB
testcase_18 WA -
testcase_19 AC 103 ms
88,404 KB
testcase_20 AC 93 ms
83,788 KB
testcase_21 AC 82 ms
77,944 KB
testcase_22 AC 108 ms
94,176 KB
testcase_23 AC 116 ms
97,992 KB
testcase_24 AC 98 ms
88,892 KB
testcase_25 AC 83 ms
79,168 KB
testcase_26 AC 115 ms
98,724 KB
testcase_27 AC 120 ms
99,236 KB
testcase_28 AC 103 ms
90,668 KB
testcase_29 AC 95 ms
85,568 KB
testcase_30 WA -
testcase_31 AC 103 ms
88,008 KB
testcase_32 WA -
testcase_33 AC 114 ms
96,692 KB
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import product
N, K = map(int, input().split())
MOD = 10**9 + 7

fact = [1]*(N+1)
rfact = [1]*(N+1)
r = 1
for i in range(1, N+1):
  fact[i] = r = r * i % MOD
rfact[N] = r = pow(fact[N], MOD-2, MOD)
for i in range(N, 0, -1):
  rfact[i-1] = r = r * i % MOD
def comb(n, k):
  return fact[n] * rfact[k] * rfact[n-k] % MOD

p = [1]*(N+1)
p[0] = p[1] = 0

vs = []
ans = 0
for x in range(2, N+1):
    if p[x] and N % x == 0 and K % x == 0:
        for y in range(x*x, N+1, x):
            p[y] = 0
        vs.append(x)

L = len(vs)
for ps in product([0, 1], repeat=L):
    e = 1
    c = 0
    for p, v in zip(ps, vs):
        if p:
            c ^= 1
            e *= v
    if e == 1:
        continue
    ans += comb(N//e, K//e) if c else -comb(N//e, K//e)
print(ans)
0