結果

問題 No.2365 Present of good number
ユーザー tassei903tassei903
提出日時 2023-06-30 22:03:07
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,092 bytes
コンパイル時間 361 ms
コンパイル使用メモリ 87,048 KB
実行使用メモリ 86,124 KB
最終ジャッジ日時 2023-09-21 16:03:44
合計ジャッジ時間 6,822 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
79,732 KB
testcase_01 AC 121 ms
80,028 KB
testcase_02 RE -
testcase_03 AC 121 ms
79,764 KB
testcase_04 AC 122 ms
79,768 KB
testcase_05 AC 121 ms
79,764 KB
testcase_06 AC 121 ms
80,080 KB
testcase_07 AC 123 ms
80,032 KB
testcase_08 AC 119 ms
79,800 KB
testcase_09 AC 119 ms
79,712 KB
testcase_10 AC 121 ms
79,880 KB
testcase_11 AC 120 ms
79,772 KB
testcase_12 AC 121 ms
80,072 KB
testcase_13 AC 121 ms
79,756 KB
testcase_14 AC 122 ms
79,784 KB
testcase_15 AC 121 ms
79,764 KB
testcase_16 AC 121 ms
79,796 KB
testcase_17 AC 121 ms
80,028 KB
testcase_18 AC 120 ms
79,716 KB
testcase_19 AC 119 ms
79,892 KB
testcase_20 AC 119 ms
79,676 KB
testcase_21 AC 120 ms
79,764 KB
testcase_22 AC 121 ms
80,052 KB
testcase_23 AC 119 ms
79,924 KB
testcase_24 AC 120 ms
79,628 KB
testcase_25 AC 120 ms
79,580 KB
testcase_26 AC 119 ms
79,764 KB
testcase_27 AC 119 ms
80,064 KB
testcase_28 AC 119 ms
80,016 KB
testcase_29 AC 121 ms
79,768 KB
testcase_30 AC 120 ms
79,652 KB
testcase_31 AC 121 ms
79,968 KB
testcase_32 AC 120 ms
79,916 KB
testcase_33 AC 122 ms
79,880 KB
testcase_34 AC 122 ms
80,032 KB
testcase_35 AC 121 ms
79,988 KB
testcase_36 AC 123 ms
79,792 KB
testcase_37 AC 122 ms
79,824 KB
testcase_38 AC 123 ms
79,896 KB
testcase_39 AC 123 ms
79,672 KB
testcase_40 AC 122 ms
80,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 10**9+7
n,k = map(int, input().split())

m = 10**5
a = [-1] * m
p = []
d = dict()
for i in range(2, m):
    if a[i] == -1:
        d[i] = len(p)
        p.append(i)
        for j in range(i, m, i):
            a[j] = i
pl = len(p)

from collections import defaultdict
def f(x):
    res = defaultdict(int)
    while x != 1:
        q = a[x]
        c = 0
        while x % q == 0:
            x //= q
            c += 1
        res[q] = c
    return res

def g(a, b, k):
    if k % 2 == 0:
        return pow(2, pow(2, k//2, mod-1)*a, mod)*pow(3, pow(2, k//2, mod-1)*b, mod)%mod
    else:
        return pow(2, pow(2, (k+1)//2, mod-1)*b, mod)*pow(3, pow(2, k//2, mod-1)*a, mod)%mod

b = []
for q in p:
    b.append(f(q+1))

c = f(n)
for i in range(k):
    if len(c) <= 2 and sum([x == 2 or x == 3 for x in c]) == len(c):
        print(g(c[2], c[3], k-i))
        exit()
    nxt = defaultdict(int)
    for q in c:
        for r in b[d[q]]:
            nxt[r] += b[d[q]][r] * c[q] 
    c = nxt
    #print(c)
    
ans = 1

for i in c:
    ans *= pow(i, c[i], mod)
    ans %= mod
print(ans)
0