結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,672 KB
testcase_01 AC 70 ms
71,540 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 69 ms
71,520 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,724 KB
testcase_18 AC 69 ms
71,672 KB
testcase_19 WA -
testcase_20 AC 71 ms
71,656 KB
testcase_21 AC 73 ms
75,708 KB
testcase_22 WA -
testcase_23 AC 73 ms
75,876 KB
testcase_24 AC 73 ms
75,660 KB
testcase_25 WA -
testcase_26 AC 74 ms
75,584 KB
testcase_27 AC 74 ms
75,692 KB
testcase_28 AC 73 ms
75,744 KB
testcase_29 AC 73 ms
75,796 KB
testcase_30 AC 73 ms
75,740 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 70 ms
71,656 KB
testcase_37 AC 71 ms
75,624 KB
testcase_38 AC 71 ms
75,624 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
    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)
0