結果

問題 No.2365 Present of good number
ユーザー rlangevinrlangevin
提出日時 2023-06-30 21:55:52
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,107 bytes
コンパイル時間 332 ms
コンパイル使用メモリ 87,160 KB
実行使用メモリ 72,424 KB
最終ジャッジ日時 2023-09-21 15:51:03
合計ジャッジ時間 5,428 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
71,744 KB
testcase_01 AC 90 ms
71,948 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 90 ms
72,140 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 AC 90 ms
72,068 KB
testcase_17 AC 87 ms
71,964 KB
testcase_18 AC 90 ms
71,940 KB
testcase_19 AC 89 ms
71,856 KB
testcase_20 AC 90 ms
71,844 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 91 ms
71,584 KB
testcase_32 AC 91 ms
71,952 KB
testcase_33 AC 90 ms
71,948 KB
testcase_34 AC 90 ms
71,860 KB
testcase_35 AC 90 ms
72,048 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *

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])

    return arr

N, K = map(int, input().split())
mod = 10**9 + 7
ans = 1
D = defaultdict(int)
for i, cnt in factorization(N):
    D[i] += cnt
    
while K:
    new = defaultdict(int)
    if len(D) == 1:
        if 2 in D or 3 in D:
            break
    if len(D) == 2:
        if 2 in D and 3 in D:
            break
    K -= 1
    for k, v in D.items():
        for i, cnt in factorization(k + 1):
            new[i] += cnt
    new, D = D, new    
    
if K == 0:
    ans = 1
    for k, v in D.items():
        ans *= pow(k, v, mod)
        ans %= mod
    print(ans)
else:
    m = K//2
    K %= 2
    D[2] = D[2] * pow(2, m, mod - 1)
    D[3] = D[3] * pow(2, m, mod - 1)
    if K:
        D[2], D[3] = D[3] * 2, D[2]
    ans = pow(2, D[2], mod) * pow(3, D[3], mod) % mod
    print(ans)
0