結果

問題 No.2365 Present of good number
ユーザー 👑 H20H20
提出日時 2023-07-04 12:41:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 914 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 87,140 KB
実行使用メモリ 71,660 KB
最終ジャッジ日時 2023-09-25 10:37:22
合計ジャッジ時間 7,080 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
71,508 KB
testcase_01 AC 92 ms
71,528 KB
testcase_02 AC 92 ms
71,288 KB
testcase_03 AC 95 ms
71,188 KB
testcase_04 AC 90 ms
71,512 KB
testcase_05 AC 92 ms
71,408 KB
testcase_06 AC 92 ms
71,632 KB
testcase_07 AC 93 ms
71,288 KB
testcase_08 AC 93 ms
71,636 KB
testcase_09 AC 92 ms
71,460 KB
testcase_10 AC 92 ms
71,544 KB
testcase_11 AC 90 ms
71,528 KB
testcase_12 AC 92 ms
71,400 KB
testcase_13 AC 90 ms
71,140 KB
testcase_14 AC 91 ms
71,432 KB
testcase_15 AC 91 ms
71,544 KB
testcase_16 AC 91 ms
71,360 KB
testcase_17 AC 90 ms
71,292 KB
testcase_18 AC 89 ms
71,660 KB
testcase_19 AC 91 ms
71,536 KB
testcase_20 AC 92 ms
71,408 KB
testcase_21 AC 91 ms
71,408 KB
testcase_22 AC 93 ms
71,588 KB
testcase_23 AC 92 ms
71,292 KB
testcase_24 AC 94 ms
71,620 KB
testcase_25 AC 93 ms
71,292 KB
testcase_26 AC 90 ms
71,476 KB
testcase_27 AC 90 ms
71,432 KB
testcase_28 AC 90 ms
71,548 KB
testcase_29 AC 91 ms
71,536 KB
testcase_30 AC 91 ms
71,388 KB
testcase_31 AC 91 ms
71,492 KB
testcase_32 AC 91 ms
71,460 KB
testcase_33 AC 92 ms
71,484 KB
testcase_34 AC 93 ms
71,616 KB
testcase_35 AC 91 ms
71,612 KB
testcase_36 AC 93 ms
71,588 KB
testcase_37 AC 91 ms
71,640 KB
testcase_38 AC 91 ms
71,308 KB
testcase_39 AC 91 ms
71,236 KB
testcase_40 AC 94 ms
71,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


N,K = map(int,input().split())
P = prime_factorize(N)
C = collections.Counter(P)
mod = 10**9+7
for _ in range(min(30,K)):
    NC = collections.Counter()
    for k,v in C.items():
        for p in prime_factorize(k+1):
            NC[p]+=v
    C = NC
K = K-min(K,30)
if K==0:
    ans = 1
    for k,v in C.items():
        ans=ans*pow(k,v,mod)%mod
    print(ans)
else:
    if K%2==1:
        NC = collections.Counter()
        for k,v in C.items():
            for p in prime_factorize(k+1):
                NC[p]+=v
        C = NC
    K2=K//2
    print(pow(2,C[2]*pow(2,K2,mod-1),mod)*pow(3,C[3]*pow(2,K2,mod-1),mod)%mod)
0