結果
| 問題 | No.2007 Arbitrary Mod (Easy) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-03-05 10:55:52 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
AC
|
| 実行時間 | 97 ms / 2,000 ms |
| コード長 | 446 bytes |
| 記録 | |
| コンパイル時間 | 353 ms |
| コンパイル使用メモリ | 20,568 KB |
| 実行使用メモリ | 15,452 KB |
| 最終ジャッジ日時 | 2026-04-06 12:49:31 |
| 合計ジャッジ時間 | 5,537 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
def fast_exp_mod(k,n,MOD):
import math
ans = 1
temp = k%MOD
a = [temp]
saidai = int(math.log2(n))+1
for _ in range(saidai):
temp = temp**2 % MOD
a.append(temp)
for i in range(saidai):
if n & 1 << i:
ans = ans*a[i] % MOD
return ans
def Main():
a,n=map(int,input().split())
MOD=998244353
print(MOD)
print(fast_exp_mod(a,n,MOD))
Main()