結果
| 問題 |
No.2365 Present of good number
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-06-30 22:18:18 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 990 bytes |
| コンパイル時間 | 214 ms |
| コンパイル使用メモリ | 82,104 KB |
| 実行使用メモリ | 57,116 KB |
| 最終ジャッジ日時 | 2024-07-07 10:07:43 |
| 合計ジャッジ時間 | 2,604 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 12 WA * 27 |
ソースコード
import sys
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline
from collections import defaultdict, deque, Counter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
from math import gcd
mod = 10**9+7
def fact(n):
l = []
tmp = n
for i in range(2,int(pow(n,0.5))+1):
if tmp % i == 0:
cnt = 0
while tmp % i == 0:
cnt += 1
tmp //= i
l.append([i,cnt])
if tmp != 1:
l.append([tmp,1])
return l
def gu(p, cnt):
if cnt == 0:
return p
pf = fact(p)
ans = 1
for i in pf:
if i[0] != 2:
ans *= pow(gu(i[0]+1,cnt-1), i[1], mod)
else:
if cnt % 2 == 0:
ans *= pow(pow(2, pow(2,cnt//2, mod-1), mod),i[1], mod)
else:
ans *= pow(pow(3, pow(2,cnt//2, mod-1), mod), i[1],mod)
ans %= mod
return ans
n,k = map(int,input().split())
print(gu(n,k))