結果
問題 | No.2365 Present of good number |
ユーザー | lloyz |
提出日時 | 2023-06-30 22:37:27 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,706 bytes |
コンパイル時間 | 148 ms |
コンパイル使用メモリ | 82,036 KB |
実行使用メモリ | 67,080 KB |
最終ジャッジ日時 | 2024-07-07 10:28:15 |
合計ジャッジ時間 | 3,398 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 56 ms
65,888 KB |
testcase_01 | AC | 53 ms
65,956 KB |
testcase_02 | WA | - |
testcase_03 | AC | 52 ms
65,724 KB |
testcase_04 | AC | 52 ms
65,068 KB |
testcase_05 | AC | 50 ms
64,848 KB |
testcase_06 | AC | 53 ms
64,288 KB |
testcase_07 | AC | 53 ms
65,744 KB |
testcase_08 | AC | 57 ms
65,836 KB |
testcase_09 | AC | 52 ms
65,840 KB |
testcase_10 | AC | 53 ms
65,364 KB |
testcase_11 | AC | 52 ms
64,860 KB |
testcase_12 | AC | 54 ms
65,192 KB |
testcase_13 | AC | 53 ms
65,680 KB |
testcase_14 | WA | - |
testcase_15 | AC | 54 ms
65,568 KB |
testcase_16 | AC | 51 ms
65,312 KB |
testcase_17 | AC | 53 ms
64,896 KB |
testcase_18 | AC | 52 ms
65,200 KB |
testcase_19 | AC | 51 ms
65,748 KB |
testcase_20 | AC | 51 ms
65,024 KB |
testcase_21 | AC | 52 ms
64,960 KB |
testcase_22 | AC | 53 ms
64,984 KB |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | AC | 52 ms
64,616 KB |
testcase_26 | AC | 52 ms
65,568 KB |
testcase_27 | AC | 52 ms
65,340 KB |
testcase_28 | AC | 55 ms
64,644 KB |
testcase_29 | AC | 51 ms
66,028 KB |
testcase_30 | AC | 53 ms
65,408 KB |
testcase_31 | AC | 53 ms
64,700 KB |
testcase_32 | AC | 53 ms
65,288 KB |
testcase_33 | AC | 54 ms
64,948 KB |
testcase_34 | WA | - |
testcase_35 | AC | 52 ms
65,764 KB |
testcase_36 | AC | 53 ms
64,828 KB |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | AC | 52 ms
66,372 KB |
ソースコード
from collections import defaultdict IsPrime = [True for _ in range(10**5 + 1)] IsPrime[0] = IsPrime[1] = False Primes = [] for i in range(2, 10**5 + 1): if IsPrime[i]: Primes.append(i) for j in range(i * i, 10**5 + 1, i): IsPrime[j] = False n, k = map(int, input().split()) mod = 10**9 + 7 P = defaultdict(int) seen = set() for prime in Primes: while n % prime == 0: seen.add(prime) P[prime] += 1 n //= prime C = [(p, c) for p, c in P.items()] while not (len(seen) <= 2 and (2 in seen or 3 in seen)) and k > 0: k -= 1 P = defaultdict(int) seen = set() for p, c in C: p += 1 if IsPrime[p]: seen.add(p) P[p] += c P[p] %= mod - 1 else: for prime in Primes: while p % prime == 0: seen.add(prime) P[prime] += c P[prime] %= mod - 1 p //= prime if p == 1: break C = [(p, c) for p, c in P.items()] if k > 0: q, r = divmod(k, 2) P = defaultdict(int) for p, c in C: if p == 2: if r == 0: P[2] += c * pow(2, q, mod - 1) P[2] %= mod - 1 else: P[3] += c * pow(2, q, mod - 1) P[3] %= mod - 1 else: if r == 0: P[3] += c * pow(2, q, mod - 1) P[3] %= mod - 1 else: P[2] += c * pow(2, q + 1, mod - 1) P[2] %= mod - 1 C = [(p, c) for p, c in P.items()] ans = 1 for p, c in C: ans *= pow(p, c, mod) ans %= mod print(ans)