結果

問題 No.1092 modular arithmetic
ユーザー Keroru
提出日時 2020-06-25 19:23:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,141 ms / 2,000 ms
コード長 237 bytes
コンパイル時間 139 ms
コンパイル使用メモリ 82,064 KB
実行使用メモリ 115,932 KB
最終ジャッジ日時 2024-07-03 21:42:41
合計ジャッジ時間 22,750 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

p,n=map(int,input().split())
a=list(map(int,input().split()))[::-1]
t=a.pop()
op=list(input())[::-1]
while op:
    x=op.pop()
    if x=='/':
        t*=pow(a.pop(),p-2,p)
    else:
        t=eval(str(t)+x+str(a.pop()))
    t%=p

print(t)
0