結果

問題 No.2365 Present of good number
ユーザー yabityabit
提出日時 2023-06-30 23:40:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 1,340 bytes
コンパイル時間 934 ms
コンパイル使用メモリ 86,760 KB
実行使用メモリ 75,992 KB
最終ジャッジ日時 2023-09-21 17:55:00
合計ジャッジ時間 5,319 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,580 KB
testcase_01 AC 68 ms
71,848 KB
testcase_02 AC 78 ms
75,452 KB
testcase_03 AC 72 ms
75,568 KB
testcase_04 AC 68 ms
71,372 KB
testcase_05 AC 70 ms
75,400 KB
testcase_06 AC 71 ms
75,608 KB
testcase_07 AC 70 ms
75,656 KB
testcase_08 AC 71 ms
75,692 KB
testcase_09 AC 70 ms
75,676 KB
testcase_10 AC 72 ms
75,408 KB
testcase_11 AC 68 ms
71,636 KB
testcase_12 AC 71 ms
75,524 KB
testcase_13 AC 74 ms
75,640 KB
testcase_14 AC 70 ms
75,540 KB
testcase_15 AC 70 ms
75,396 KB
testcase_16 AC 68 ms
71,468 KB
testcase_17 AC 68 ms
71,816 KB
testcase_18 AC 68 ms
71,796 KB
testcase_19 AC 68 ms
71,732 KB
testcase_20 AC 68 ms
71,696 KB
testcase_21 AC 70 ms
75,616 KB
testcase_22 AC 71 ms
75,528 KB
testcase_23 AC 69 ms
75,580 KB
testcase_24 AC 70 ms
75,992 KB
testcase_25 AC 72 ms
75,728 KB
testcase_26 AC 70 ms
75,540 KB
testcase_27 AC 69 ms
75,648 KB
testcase_28 AC 72 ms
75,496 KB
testcase_29 AC 72 ms
75,456 KB
testcase_30 AC 73 ms
75,584 KB
testcase_31 AC 70 ms
71,644 KB
testcase_32 AC 70 ms
71,840 KB
testcase_33 AC 69 ms
71,624 KB
testcase_34 AC 69 ms
71,572 KB
testcase_35 AC 70 ms
71,500 KB
testcase_36 AC 68 ms
71,820 KB
testcase_37 AC 70 ms
75,508 KB
testcase_38 AC 71 ms
75,624 KB
testcase_39 AC 70 ms
75,624 KB
testcase_40 AC 80 ms
75,952 KB
権限があれば一括ダウンロードができます

ソースコード

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
    if flag:
        amari = K - i
        if len(ft) == 1:
            if ft[0][0] == 2:
                ft.append([3, 0])
            else:
                ft.insert(0, [2, 0])
        k2, k3 = ft[0][1], ft[1][1]
        if amari % 2 == 0:
            two = pow(2, pow(2, amari // 2, MOD-1) * k2, MOD)
            three = pow(3, pow(2, amari // 2, MOD-1) * k3, MOD)
        else:
            two = pow(2, pow(2, (amari + 1) // 2, MOD-1) * k3, MOD)
            three = pow(3, pow(2, amari // 2, MOD-1) * k2, MOD)
        # print(amari, two, three, two * three, pow(2, amari // 2, MOD))
        N = (two * three) % MOD
        break
    else:
        N = c
print(N % MOD)
0