結果

問題 No.2365 Present of good number
ユーザー ntudantuda
提出日時 2023-07-01 17:32:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 960 bytes
コンパイル時間 358 ms
コンパイル使用メモリ 87,136 KB
実行使用メモリ 71,916 KB
最終ジャッジ日時 2023-09-22 11:45:28
合計ジャッジ時間 6,528 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
71,508 KB
testcase_01 AC 96 ms
71,836 KB
testcase_02 AC 94 ms
71,712 KB
testcase_03 AC 94 ms
71,560 KB
testcase_04 AC 96 ms
71,696 KB
testcase_05 AC 95 ms
71,692 KB
testcase_06 AC 94 ms
71,632 KB
testcase_07 AC 96 ms
71,632 KB
testcase_08 AC 94 ms
71,780 KB
testcase_09 AC 94 ms
71,468 KB
testcase_10 AC 95 ms
71,688 KB
testcase_11 AC 94 ms
71,688 KB
testcase_12 AC 93 ms
71,384 KB
testcase_13 AC 95 ms
71,656 KB
testcase_14 AC 93 ms
71,716 KB
testcase_15 AC 95 ms
71,812 KB
testcase_16 AC 93 ms
71,512 KB
testcase_17 AC 96 ms
71,808 KB
testcase_18 AC 96 ms
71,328 KB
testcase_19 AC 95 ms
71,720 KB
testcase_20 AC 94 ms
71,648 KB
testcase_21 AC 93 ms
71,728 KB
testcase_22 AC 95 ms
71,728 KB
testcase_23 AC 96 ms
71,504 KB
testcase_24 AC 95 ms
71,604 KB
testcase_25 AC 95 ms
71,648 KB
testcase_26 AC 94 ms
71,552 KB
testcase_27 AC 95 ms
71,384 KB
testcase_28 AC 95 ms
71,640 KB
testcase_29 AC 93 ms
71,692 KB
testcase_30 AC 95 ms
71,508 KB
testcase_31 AC 93 ms
71,584 KB
testcase_32 AC 97 ms
71,336 KB
testcase_33 AC 95 ms
71,340 KB
testcase_34 AC 93 ms
71,916 KB
testcase_35 AC 95 ms
71,772 KB
testcase_36 AC 95 ms
71,640 KB
testcase_37 AC 94 ms
71,824 KB
testcase_38 AC 94 ms
71,836 KB
testcase_39 AC 93 ms
71,784 KB
testcase_40 AC 94 ms
71,644 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
MOD = 10 ** 9 + 7
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

def n_fact(N):
    c = Counter(prime_factorize(N))
    return c

N,K = map(int,input().split())
D = n_fact(N)

for i in range(K):
    D2 = defaultdict(int)
    D2[2] = 0
    D2[3] = 0
    for k,v in D.items():
        DT = n_fact(k + 1)
        for k2, v2 in DT.items():
            D2[k2] += v * v2
    D = D2
    if D.keys() == {2,3}:
        break
K -= i + 1
if K == 0:
    ans = 1
    for k,v in D.items():
        ans *= pow(k,v,MOD)
    ans %= MOD
    print(ans)
    exit()

A = [D[2],D[3]]
if K & 1:
    A = [A[1] * 2, A[0]]

ans = pow(2,A[0] * pow(2,K//2,MOD-1),MOD)
ans *= pow(3,A[1] * pow(2,K//2,MOD-1),MOD)
ans %= MOD
print(ans)


0