結果
問題 |
No.1092 modular arithmetic
|
ユーザー |
![]() |
提出日時 | 2020-07-18 22:11:56 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 329 bytes |
コンパイル時間 | 208 ms |
コンパイル使用メモリ | 82,324 KB |
実行使用メモリ | 82,524 KB |
最終ジャッジ日時 | 2024-12-14 09:38:36 |
合計ジャッジ時間 | 4,319 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 |
other | AC * 23 WA * 9 |
ソースコード
import sys input=lambda: sys.stdin.readline().rstrip() p,n=map(int,input().split()) A=[int(i) for i in input().split()] S=input() ans=A[0] for i in range(n-1): if S[i]=="+": ans=ans+A[i+1] if S[i]=="-": ans=ans-A[i+1] if S[i]=="*": ans=(ans*A[i+1])%p if S[i]=="/": ans=(ans*pow(A[i+1],p-2,p))%p print(ans)