結果

問題 No.2365 Present of good number
ユーザー miya145592miya145592
提出日時 2023-06-30 23:49:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 1,220 bytes
コンパイル時間 654 ms
コンパイル使用メモリ 86,716 KB
実行使用メモリ 72,200 KB
最終ジャッジ日時 2023-09-21 17:58:01
合計ジャッジ時間 6,004 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
71,900 KB
testcase_01 AC 99 ms
71,860 KB
testcase_02 AC 98 ms
72,200 KB
testcase_03 AC 99 ms
72,056 KB
testcase_04 AC 99 ms
72,128 KB
testcase_05 AC 99 ms
72,004 KB
testcase_06 AC 98 ms
72,052 KB
testcase_07 AC 101 ms
72,000 KB
testcase_08 AC 99 ms
72,032 KB
testcase_09 AC 99 ms
71,856 KB
testcase_10 AC 98 ms
71,720 KB
testcase_11 AC 101 ms
72,016 KB
testcase_12 AC 99 ms
71,848 KB
testcase_13 AC 100 ms
72,028 KB
testcase_14 AC 98 ms
72,124 KB
testcase_15 AC 99 ms
72,116 KB
testcase_16 AC 99 ms
72,116 KB
testcase_17 AC 96 ms
71,944 KB
testcase_18 AC 98 ms
71,852 KB
testcase_19 AC 99 ms
71,728 KB
testcase_20 AC 97 ms
71,992 KB
testcase_21 AC 97 ms
71,940 KB
testcase_22 AC 100 ms
71,892 KB
testcase_23 AC 98 ms
71,964 KB
testcase_24 AC 97 ms
71,876 KB
testcase_25 AC 99 ms
71,992 KB
testcase_26 AC 100 ms
72,088 KB
testcase_27 AC 99 ms
71,892 KB
testcase_28 AC 98 ms
72,016 KB
testcase_29 AC 99 ms
71,988 KB
testcase_30 AC 98 ms
72,000 KB
testcase_31 AC 98 ms
71,772 KB
testcase_32 AC 99 ms
72,052 KB
testcase_33 AC 97 ms
71,900 KB
testcase_34 AC 97 ms
72,076 KB
testcase_35 AC 98 ms
72,108 KB
testcase_36 AC 100 ms
71,948 KB
testcase_37 AC 98 ms
71,836 KB
testcase_38 AC 99 ms
71,864 KB
testcase_39 AC 97 ms
72,088 KB
testcase_40 AC 100 ms
71,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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-1)
            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-1) % (MOD-1)
    e3 = dp[3] * pow(2, (nokori//2), MOD-1) % (MOD-1)
    if nokori%2==1:
        e3, e2 = e2, e3*2%(MOD-1)
    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)
0