結果
問題 |
No.1092 modular arithmetic
|
ユーザー |
![]() |
提出日時 | 2020-07-18 22:26:15 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 466 ms / 2,000 ms |
コード長 | 321 bytes |
コンパイル時間 | 205 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 21,856 KB |
最終ジャッジ日時 | 2024-12-14 10:24:06 |
合計ジャッジ時間 | 7,788 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 32 |
ソースコード
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+=A[i+1] if S[i]=="-": ans-=A[i+1] if S[i]=="*": ans*=A[i+1] if S[i]=="/": ans=ans*pow(A[i+1],p-2,p) ans%=p print(ans)