結果

問題 No.251 大きな桁の復習問題(1)
ユーザー Mao-beta
提出日時 2025-02-13 18:22:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 60 ms / 5,000 ms
コード長 1,036 bytes
コンパイル時間 2,761 ms
コンパイル使用メモリ 82,016 KB
実行使用メモリ 71,584 KB
最終ジャッジ日時 2025-02-13 18:22:16
合計ジャッジ時間 3,423 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import math
import bisect
from heapq import heapify, heappop, heappush
from collections import deque, defaultdict, Counter
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product

sys.set_int_max_str_digits(10 ** 6)
sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
MOD99 = 998244353

input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()
SMI = lambda: input().split()
SLI = lambda: list(SMI())
EI = lambda m: [NLI() for _ in range(m)]


def main():
    p = 129402307
    N = SI()
    M = SI()

    if N[0] == "0":
        print(0)
        return
    if M[0] == "0":
        print(1)
        return

    n = 0
    for s in N:
        n = (n*10+int(s)) % p

    m = 0
    for s in M:
        m = (m*10+int(s)) % (p-1)

    if n == 0:
        print(0)
        return
    if m == 0:
        print(1)
        return
    print(pow(n, m, p))


if __name__ == "__main__":
    main()
0