結果

問題 No.2365 Present of good number
ユーザー ShirotsumeShirotsume
提出日時 2023-06-30 22:36:29
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,119 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 87,112 KB
実行使用メモリ 90,972 KB
最終ジャッジ日時 2023-09-21 16:46:18
合計ジャッジ時間 9,794 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 147 ms
87,272 KB
testcase_01 AC 151 ms
87,020 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 AC 146 ms
87,132 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 142 ms
87,396 KB
testcase_17 AC 143 ms
87,328 KB
testcase_18 AC 145 ms
87,212 KB
testcase_19 AC 145 ms
87,052 KB
testcase_20 AC 152 ms
86,868 KB
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 AC 144 ms
87,204 KB
testcase_37 AC 145 ms
87,372 KB
testcase_38 AC 145 ms
87,212 KB
testcase_39 RE -
testcase_40 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, time, random
from collections import deque, Counter, defaultdict
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 63 - 1
mod = 10 ** 9 + 7
maxi = 10 ** 6 + 100
prime = [i for i in range(maxi)]
for i in range(2, maxi):
    if prime[i] == i:
        for j in range(2 * i, maxi, i):
            prime[j] = i
 
n, k = mi()

while k > 0:
    now = n
    C = Counter()
    while now > 1:
        C[prime[now]] += 1
        now //= prime[now]
    
    S = set(C.keys())
    S.discard(2)
    S.discard(3)
    if S:
        k -= 1
        n = 1
        for v, c in C.items():
            n *= pow(v + 1, c)
    else:
        break
if k == 0:
    ans = n
else:
    p = 0
    while n % 2 == 0:
        p += 1
        n //= 2
    q = 0
    while n % 3 == 0:
        q += 1
        n //= 3
    
    q = pow(2, (k + 1) // 2) * q
    p = pow(2, k // 2) * p
    if k % 2:
        ans = pow(2, q, mod) * pow(3, p, mod)
        ans %= mod
    else:
        ans = pow(2, p, mod) * pow(3, q, mod)
        ans %= mod
print(ans)



0