結果
問題 | No.890 移調の限られた旋法 |
ユーザー | Salmonize |
提出日時 | 2020-05-04 16:01:23 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,141 bytes |
コンパイル時間 | 83 ms |
コンパイル使用メモリ | 11,084 KB |
実行使用メモリ | 105,844 KB |
最終ジャッジ日時 | 2023-09-06 17:43:42 |
合計ジャッジ時間 | 32,821 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 712 ms
86,596 KB |
testcase_01 | AC | 681 ms
86,932 KB |
testcase_02 | AC | 734 ms
86,980 KB |
testcase_03 | AC | 732 ms
86,884 KB |
testcase_04 | AC | 693 ms
86,928 KB |
testcase_05 | AC | 689 ms
87,000 KB |
testcase_06 | AC | 692 ms
86,888 KB |
testcase_07 | AC | 703 ms
87,040 KB |
testcase_08 | AC | 705 ms
86,868 KB |
testcase_09 | AC | 692 ms
87,052 KB |
testcase_10 | AC | 691 ms
86,812 KB |
testcase_11 | AC | 693 ms
86,880 KB |
testcase_12 | AC | 688 ms
86,924 KB |
testcase_13 | WA | - |
testcase_14 | AC | 914 ms
105,708 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 823 ms
96,752 KB |
testcase_20 | AC | 785 ms
93,356 KB |
testcase_21 | AC | 699 ms
88,200 KB |
testcase_22 | AC | 894 ms
101,316 KB |
testcase_23 | AC | 916 ms
104,556 KB |
testcase_24 | AC | 870 ms
97,176 KB |
testcase_25 | AC | 773 ms
89,224 KB |
testcase_26 | WA | - |
testcase_27 | AC | 1,002 ms
105,116 KB |
testcase_28 | AC | 873 ms
98,884 KB |
testcase_29 | AC | 783 ms
94,656 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*p] print(sum(res))