結果
問題 | No.890 移調の限られた旋法 |
ユーザー | Salmonize |
提出日時 | 2020-05-04 16:03:21 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,163 bytes |
コンパイル時間 | 75 ms |
コンパイル使用メモリ | 11,124 KB |
実行使用メモリ | 105,776 KB |
最終ジャッジ日時 | 2023-09-06 17:48:18 |
合計ジャッジ時間 | 32,456 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 685 ms
86,948 KB |
testcase_01 | AC | 687 ms
87,032 KB |
testcase_02 | AC | 702 ms
86,872 KB |
testcase_03 | AC | 691 ms
86,952 KB |
testcase_04 | AC | 696 ms
86,836 KB |
testcase_05 | AC | 687 ms
86,892 KB |
testcase_06 | AC | 687 ms
86,948 KB |
testcase_07 | AC | 721 ms
86,932 KB |
testcase_08 | AC | 694 ms
87,040 KB |
testcase_09 | AC | 737 ms
86,504 KB |
testcase_10 | AC | 698 ms
86,896 KB |
testcase_11 | AC | 700 ms
86,916 KB |
testcase_12 | AC | 708 ms
86,848 KB |
testcase_13 | WA | - |
testcase_14 | AC | 945 ms
105,652 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 893 ms
96,960 KB |
testcase_20 | AC | 784 ms
93,460 KB |
testcase_21 | AC | 712 ms
88,184 KB |
testcase_22 | AC | 908 ms
101,236 KB |
testcase_23 | AC | 997 ms
104,472 KB |
testcase_24 | AC | 857 ms
97,064 KB |
testcase_25 | AC | 731 ms
89,216 KB |
testcase_26 | WA | - |
testcase_27 | AC | 977 ms
105,252 KB |
testcase_28 | AC | 905 ms
98,608 KB |
testcase_29 | AC | 803 ms
94,836 KB |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
ソースコード
def divisor(n): ass = [] for i in range(1, int((n+1)**0.5)+1): if n%i == 0: ass.append(i) if i*i < n: ass.append(n//i) return ass #sortされていない def primes(n): is_prime = [True] * (n + 1) is_prime[0] = is_prime[1] = False for i in range(2, int((n+1)**0.5)+1): if is_prime[i]: for j in range(i *2, n + 1, i): is_prime[j] = False res = [i for i in range(n+1) if is_prime[i]] return res 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) for x in set(divisor(n)) & set(divisor(k)): res[x] = nCr(n//x, k//x) res[1] = 0 prl = primes(n) for i in range(n+1): if res[i]: for p in prl: if i*p > n: break res[i] = (res[i] - res[i*p]) % mod print(sum(res) % mod)