結果
問題 | No.2365 Present of good number |
ユーザー | miya145592 |
提出日時 | 2023-06-30 23:37:13 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,200 bytes |
コンパイル時間 | 361 ms |
コンパイル使用メモリ | 87,264 KB |
実行使用メモリ | 72,368 KB |
最終ジャッジ日時 | 2023-09-21 17:52:24 |
合計ジャッジ時間 | 6,295 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 98 ms
72,096 KB |
testcase_01 | AC | 98 ms
71,736 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | AC | 97 ms
71,920 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | AC | 98 ms
71,972 KB |
testcase_18 | AC | 99 ms
71,960 KB |
testcase_19 | WA | - |
testcase_20 | AC | 95 ms
71,928 KB |
testcase_21 | AC | 96 ms
72,192 KB |
testcase_22 | WA | - |
testcase_23 | AC | 97 ms
72,000 KB |
testcase_24 | AC | 95 ms
71,840 KB |
testcase_25 | WA | - |
testcase_26 | AC | 96 ms
71,856 KB |
testcase_27 | AC | 97 ms
71,960 KB |
testcase_28 | AC | 97 ms
71,960 KB |
testcase_29 | AC | 99 ms
72,096 KB |
testcase_30 | AC | 95 ms
71,924 KB |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | AC | 95 ms
71,732 KB |
testcase_37 | AC | 96 ms
71,872 KB |
testcase_38 | AC | 96 ms
72,288 KB |
testcase_39 | AC | 95 ms
72,176 KB |
testcase_40 | AC | 96 ms
71,732 KB |
ソースコード
def factorization(n): arr = [] temp = n for i in range(2, int(-(-n**0.5//1))+1): if temp%i==0: cnt=0 while temp%i==0: cnt+=1 temp //= i arr.append([i, cnt]) if temp!=1: arr.append([temp, 1]) if arr==[]: arr.append([n, 1]) return arr from collections import defaultdict MOD = 10**9+7 N, K = map(int, input().split()) dp = defaultdict(int) F = factorization(N) for p, e in F: dp[p] += e dp[p] %= MOD #print(dp) for k in range(K): ndp = defaultdict(int) flag = 1 for p in dp: e = dp[p] y = factorization(p+1) for yp, ye in y: ndp[yp] += ye*e ndp[yp] %= MOD if yp>=4: flag = 0 dp = ndp if flag: break #print(dp) if flag: nokori = K-(k+1) e2 = dp[2] * pow(2, (nokori//2), MOD) % MOD e3 = dp[3] * pow(2, (nokori//2), MOD) % MOD if nokori%2==1: e3, e2 = e2, e3*2%MOD ans = pow(2, e2, MOD) * pow(3, e3, MOD) % MOD print(ans) else: ans = 1 for p in dp: e = dp[p] ans *= (p**e)%MOD ans %= MOD print(ans)