結果

問題 No.251 大きな桁の復習問題(1)
コンテスト
ユーザー norioc
提出日時 2024-07-02 01:46:13
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 512 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 341 ms
コンパイル使用メモリ 84,932 KB
実行使用メモリ 65,664 KB
最終ジャッジ日時 2026-03-23 05:35:12
合計ジャッジ時間 2,153 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def modpow(n: str, m: str, mod: int) -> int:
    """巨大数 n, m の n^m % mod を求める (mod は素数)"""
    def modulo(s: str, m: int) -> int:
        """s % m を求める (s は巨大なので文字列)"""
        x = 0
        for c in map(int, s):
            x = (10*x + c) % m
        return x

    a = modulo(n, mod)
    if a == 0: return 0
    b = modulo(m, mod-1)
    # print(f'{a=} {b=}')
    return pow(a, b, mod)


MOD = 129402307
N = input()
M = input()

ans = modpow(N, M, MOD)
print(ans)
0