結果

問題 No.1092 modular arithmetic
ユーザー tanon710tanon710
提出日時 2020-07-08 00:16:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 120 ms / 2,000 ms
コード長 436 bytes
コンパイル時間 208 ms
コンパイル使用メモリ 82,576 KB
実行使用メモリ 88,088 KB
最終ジャッジ日時 2024-04-09 21:49:27
合計ジャッジ時間 4,139 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,148 KB
testcase_01 AC 61 ms
84,556 KB
testcase_02 AC 34 ms
52,528 KB
testcase_03 AC 83 ms
88,088 KB
testcase_04 AC 78 ms
83,304 KB
testcase_05 AC 77 ms
83,524 KB
testcase_06 AC 69 ms
77,068 KB
testcase_07 AC 76 ms
83,112 KB
testcase_08 AC 78 ms
85,072 KB
testcase_09 AC 74 ms
82,448 KB
testcase_10 AC 72 ms
78,624 KB
testcase_11 AC 73 ms
80,012 KB
testcase_12 AC 70 ms
77,364 KB
testcase_13 AC 58 ms
76,652 KB
testcase_14 AC 58 ms
79,736 KB
testcase_15 AC 46 ms
65,912 KB
testcase_16 AC 54 ms
74,664 KB
testcase_17 AC 57 ms
78,964 KB
testcase_18 AC 82 ms
84,852 KB
testcase_19 AC 68 ms
77,280 KB
testcase_20 AC 86 ms
87,144 KB
testcase_21 AC 75 ms
82,028 KB
testcase_22 AC 82 ms
84,732 KB
testcase_23 AC 104 ms
78,532 KB
testcase_24 AC 60 ms
66,284 KB
testcase_25 AC 93 ms
73,888 KB
testcase_26 AC 101 ms
78,224 KB
testcase_27 AC 49 ms
64,404 KB
testcase_28 AC 91 ms
75,540 KB
testcase_29 AC 120 ms
82,684 KB
testcase_30 AC 92 ms
75,792 KB
testcase_31 AC 46 ms
63,120 KB
testcase_32 AC 85 ms
72,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3

import sys
input=sys.stdin.readline

p,n=map(int,input().split())
arr=list(map(int,input().split()))
s=input()
ans=arr[0]
for i in range(1,n):
    if s[i-1]=='+':
        ans+=arr[i]
        ans%=p
    elif s[i-1]=='-':
        ans-=arr[i]
        ans%=p
    elif s[i-1]=='*':
        ans*=arr[i]
        ans%=p
    elif s[i-1]=='/':
        ans*=pow(arr[i],p-2,p)
        ans%=p
print(ans)
0