結果
| 問題 |
No.1092 modular arithmetic
|
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-20 18:40:01 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 130 ms / 2,000 ms |
| コード長 | 443 bytes |
| コンパイル時間 | 202 ms |
| コンパイル使用メモリ | 82,344 KB |
| 実行使用メモリ | 90,900 KB |
| 最終ジャッジ日時 | 2025-03-20 18:40:08 |
| 合計ジャッジ時間 | 4,321 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 32 |
ソースコード
p, n = map(int, input().split())
a = list(map(int, input().split()))
s = input().strip()
current = a[0] % p
for i in range(1, n):
op = s[i-1]
num = a[i] % p
if op == '+':
current = (current + num) % p
elif op == '-':
current = (current - num) % p
elif op == '*':
current = (current * num) % p
elif op == '/':
inv = pow(num, p-2, p)
current = (current * inv) % p
print(current)
lam6er