結果
問題 |
No.1092 modular arithmetic
|
ユーザー |
![]() |
提出日時 | 2025-03-20 20:18:01 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 123 ms / 2,000 ms |
コード長 | 443 bytes |
コンパイル時間 | 175 ms |
コンパイル使用メモリ | 82,592 KB |
実行使用メモリ | 90,756 KB |
最終ジャッジ日時 | 2025-03-20 20:18:50 |
合計ジャッジ時間 | 4,186 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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)