結果

問題 No.2365 Present of good number
ユーザー yabityabit
提出日時 2023-06-30 22:59:15
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,223 bytes
コンパイル時間 330 ms
コンパイル使用メモリ 86,888 KB
実行使用メモリ 75,984 KB
最終ジャッジ日時 2023-09-21 17:15:18
合計ジャッジ時間 5,934 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,504 KB
testcase_01 AC 75 ms
71,736 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 73 ms
71,780 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 WA -
testcase_17 AC 73 ms
71,776 KB
testcase_18 AC 74 ms
71,548 KB
testcase_19 WA -
testcase_20 AC 74 ms
71,612 KB
testcase_21 AC 77 ms
75,728 KB
testcase_22 WA -
testcase_23 AC 78 ms
75,560 KB
testcase_24 AC 78 ms
75,624 KB
testcase_25 WA -
testcase_26 AC 78 ms
75,676 KB
testcase_27 AC 77 ms
75,564 KB
testcase_28 AC 78 ms
75,584 KB
testcase_29 AC 80 ms
75,480 KB
testcase_30 AC 79 ms
75,592 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 72 ms
71,780 KB
testcase_37 AC 75 ms
75,468 KB
testcase_38 AC 76 ms
75,568 KB
testcase_39 WA -
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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])
    if arr == []:
        arr.append([n, 1])
    return arr


N, K = map(int, input().split())
MOD = 10**9 + 7
for i in range(K):
    # print(i, N, factorization(N))
    ft = factorization(N)
    c = 1
    flag = 1
    for n, k in ft:
        if n != 2 and n != 3:
            flag = 0
        c *= (n + 1) ** k
    N = c
    if flag:
        amari = K - i
        if len(ft) == 1:
            ft.append([3, 0])
        k2, k3 = ft[0][1], ft[1][1]
        if amari % 2 == 0:
            two = pow(2, pow(2, amari // 2, MOD) * k2, MOD)
            three = pow(3, pow(2, amari // 2, MOD) * k3, MOD)
        else:
            two = pow(2, pow(2, (amari + 1) // 2, MOD) * k3, MOD)
            three = pow(3, pow(2, amari // 2, MOD) * k2, MOD)
        # print(amari, two, three, two * three, pow(2, amari // 2, MOD))
        N = (two * three) % MOD
        break
print(N)
0