結果

問題 No.2365 Present of good number
ユーザー ShirotsumeShirotsume
提出日時 2023-06-30 22:42:26
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,237 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 87,176 KB
実行使用メモリ 74,532 KB
最終ジャッジ日時 2023-09-21 16:52:58
合計ジャッジ時間 7,174 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
74,472 KB
testcase_01 AC 118 ms
73,968 KB
testcase_02 AC 118 ms
74,004 KB
testcase_03 AC 119 ms
74,164 KB
testcase_04 AC 120 ms
74,352 KB
testcase_05 AC 121 ms
74,020 KB
testcase_06 AC 117 ms
74,232 KB
testcase_07 AC 120 ms
74,016 KB
testcase_08 AC 120 ms
74,448 KB
testcase_09 AC 119 ms
74,052 KB
testcase_10 AC 119 ms
74,292 KB
testcase_11 AC 126 ms
74,488 KB
testcase_12 AC 121 ms
74,232 KB
testcase_13 AC 120 ms
73,992 KB
testcase_14 AC 120 ms
74,004 KB
testcase_15 AC 120 ms
74,508 KB
testcase_16 AC 121 ms
74,340 KB
testcase_17 AC 121 ms
74,248 KB
testcase_18 AC 123 ms
74,464 KB
testcase_19 AC 119 ms
74,224 KB
testcase_20 AC 118 ms
74,464 KB
testcase_21 AC 120 ms
74,488 KB
testcase_22 AC 120 ms
74,324 KB
testcase_23 AC 119 ms
73,832 KB
testcase_24 AC 121 ms
74,216 KB
testcase_25 AC 128 ms
74,140 KB
testcase_26 AC 121 ms
74,184 KB
testcase_27 AC 121 ms
74,480 KB
testcase_28 AC 122 ms
74,464 KB
testcase_29 AC 120 ms
74,040 KB
testcase_30 AC 122 ms
73,996 KB
testcase_31 AC 121 ms
74,188 KB
testcase_32 AC 120 ms
74,196 KB
testcase_33 AC 120 ms
74,192 KB
testcase_34 AC 122 ms
74,220 KB
testcase_35 AC 122 ms
74,296 KB
testcase_36 AC 126 ms
74,468 KB
testcase_37 AC 122 ms
73,976 KB
testcase_38 AC 118 ms
74,480 KB
testcase_39 WA -
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

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())
from math import gcd
def isprime(n):
    if n <= 2:
        return n == 2
    if n % 2 == 0:
        return False
    s = 0
    t = n - 1
    while t % 2 == 0:
        s += 1
        t //= 2
    
    for a in [2,325,9375,28178,450775,9780504,1795265022]:
        if a >= n:
            break
        x = pow(a, t, n)
        if x == 1 or x == n - 1:
            continue
        for _ in range(s):
            x = (x * x) % n
            if x == n - 1:
                break
        if x == n - 1:
            continue

        return False
    return True

def Pollad(N):
    if N % 2 == 0:
        return 2
    if isprime(N):
        return N
    def f(x):
        return (x * x + 1) % N
    step = 0

    while True:
        step += 1
        x = step
        y = f(x)
        while True:
            p = gcd(y - x + N, N)
            if p == 0 or p == N:
                break
            if p != 1:
                return p
            x = f(x)
            y = f(f(y))


def Primefact(N):
    if N == 1:
        return []
    q = []
    q.append(N)
    ret = []
    while q:
        now = q.pop()
        if now == 1:
            continue
        p = Pollad(now)
        if p == now:
            ret.append(p)
        else:
            q.append(p)
            q.append(now // p)

    return Counter(ret)

mod = 10 ** 9 + 7
n, k = mi()

while k > 0:
    now = n
    C = Primefact(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, mod - 1) * q + mod - 1) % (mod - 1)
    p = (pow(2, k // 2, mod - 1) * p + mod - 1) % (mod - 1)
    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