結果

問題 No.2365 Present of good number
ユーザー aaaaaaaaaa2230
提出日時 2023-06-30 23:02:31
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 686 bytes
コンパイル時間 157 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 602,152 KB
最終ジャッジ日時 2024-07-07 10:58:22
合計ジャッジ時間 3,658 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other MLE * 1 -- * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(3*10**5)
n,k = map(int,input().split())
mod = 10**9+7

def dfs(n,k):

    if k == 0:
        return n

    if n == 1:
        return 1

    if n == 2:
        s = (k+1)//2
        p = pow(2,s,mod-1)
        if k%2:
            return pow(3,p,mod)
        else:
            return pow(2,p,mod)

    
    ans = 1
    now = n
    for i in range(2,int(n**0.5)+1):
        if now%i:
            continue
        num = 0
        while now%i == 0:
            now //= i
            num += 1
        
        ans *= pow(dfs(i+1,k-1),num,mod)
        ans %= mod

    if now != 1:
        ans *= dfs(now+1,k-1)
        ans %= mod

    return ans

print(dfs(n,k))
0