結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
74,036 KB
testcase_01 AC 117 ms
74,284 KB
testcase_02 AC 115 ms
74,072 KB
testcase_03 AC 117 ms
74,612 KB
testcase_04 AC 118 ms
74,096 KB
testcase_05 AC 115 ms
74,260 KB
testcase_06 AC 115 ms
74,560 KB
testcase_07 AC 118 ms
74,236 KB
testcase_08 AC 115 ms
74,068 KB
testcase_09 AC 118 ms
74,348 KB
testcase_10 AC 117 ms
74,264 KB
testcase_11 AC 118 ms
73,912 KB
testcase_12 AC 116 ms
74,472 KB
testcase_13 AC 116 ms
74,344 KB
testcase_14 AC 114 ms
74,240 KB
testcase_15 AC 116 ms
74,340 KB
testcase_16 AC 116 ms
74,216 KB
testcase_17 AC 115 ms
73,908 KB
testcase_18 AC 118 ms
74,336 KB
testcase_19 AC 117 ms
74,200 KB
testcase_20 AC 116 ms
74,584 KB
testcase_21 AC 117 ms
74,440 KB
testcase_22 AC 115 ms
74,616 KB
testcase_23 AC 116 ms
74,416 KB
testcase_24 AC 117 ms
74,444 KB
testcase_25 AC 116 ms
74,400 KB
testcase_26 AC 118 ms
74,468 KB
testcase_27 AC 118 ms
74,344 KB
testcase_28 AC 116 ms
74,468 KB
testcase_29 AC 118 ms
74,444 KB
testcase_30 AC 119 ms
74,392 KB
testcase_31 AC 119 ms
74,360 KB
testcase_32 AC 116 ms
74,156 KB
testcase_33 AC 118 ms
74,064 KB
testcase_34 AC 117 ms
74,336 KB
testcase_35 AC 120 ms
74,092 KB
testcase_36 AC 117 ms
74,308 KB
testcase_37 AC 117 ms
74,256 KB
testcase_38 AC 118 ms
74,260 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)
    p = (pow(2, k // 2, mod - 1) * p + 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