結果
| 問題 |
No.251 大きな桁の復習問題(1)
|
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2024-07-02 02:19:35 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 646 bytes |
| コンパイル時間 | 194 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 70,016 KB |
| 最終ジャッジ日時 | 2024-07-02 02:19:44 |
| 合計ジャッジ時間 | 2,443 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 RE * 11 |
ソースコード
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
if m == '0': return 1
a = modulo(n, mod)
if a == 0: return 0
b = modulo(m, mod-1)
return pow(a, b, mod)
def modulo(s: str, m: int) -> int:
x = 0
for c in map(int, s):
x = (10*x + c) % m
return x
MOD = 129402307
N = input()
M = input()
n = modulo(N, MOD)
ans = pow(n, int(M), MOD)
print(ans)
norioc