結果

問題 No.2365 Present of good number
ユーザー yabityabit
提出日時 2023-06-30 23:13:38
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,332 bytes
コンパイル時間 266 ms
コンパイル使用メモリ 87,144 KB
実行使用メモリ 76,160 KB
最終ジャッジ日時 2023-09-21 17:30:31
合計ジャッジ時間 4,620 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,392 KB
testcase_01 AC 68 ms
71,804 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 68 ms
71,800 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 70 ms
71,652 KB
testcase_18 AC 68 ms
71,644 KB
testcase_19 WA -
testcase_20 AC 69 ms
71,852 KB
testcase_21 AC 72 ms
75,692 KB
testcase_22 WA -
testcase_23 AC 70 ms
75,716 KB
testcase_24 AC 70 ms
76,064 KB
testcase_25 WA -
testcase_26 AC 73 ms
75,760 KB
testcase_27 AC 73 ms
75,636 KB
testcase_28 AC 73 ms
75,472 KB
testcase_29 AC 72 ms
75,756 KB
testcase_30 AC 72 ms
75,700 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 69 ms
71,768 KB
testcase_37 AC 72 ms
75,696 KB
testcase_38 AC 72 ms
75,768 KB
testcase_39 AC 73 ms
75,688 KB
testcase_40 AC 84 ms
75,712 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) * 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
    else:
        N = c
print(N % MOD)
0