結果

問題 No.1092 modular arithmetic
ユーザー ttrttr
提出日時 2020-06-28 16:03:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 372 ms / 2,000 ms
コード長 313 bytes
コンパイル時間 313 ms
コンパイル使用メモリ 10,640 KB
実行使用メモリ 19,056 KB
最終ジャッジ日時 2023-09-22 02:32:12
合計ジャッジ時間 7,900 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,680 KB
testcase_01 AC 111 ms
19,056 KB
testcase_02 AC 16 ms
7,748 KB
testcase_03 AC 174 ms
18,304 KB
testcase_04 AC 144 ms
16,456 KB
testcase_05 AC 144 ms
16,440 KB
testcase_06 AC 109 ms
14,028 KB
testcase_07 AC 136 ms
16,508 KB
testcase_08 AC 150 ms
17,252 KB
testcase_09 AC 140 ms
16,204 KB
testcase_10 AC 121 ms
15,152 KB
testcase_11 AC 135 ms
15,748 KB
testcase_12 AC 111 ms
13,980 KB
testcase_13 AC 66 ms
9,284 KB
testcase_14 AC 77 ms
9,648 KB
testcase_15 AC 29 ms
8,396 KB
testcase_16 AC 60 ms
9,128 KB
testcase_17 AC 76 ms
9,580 KB
testcase_18 AC 174 ms
18,072 KB
testcase_19 AC 112 ms
13,996 KB
testcase_20 AC 177 ms
18,328 KB
testcase_21 AC 143 ms
15,860 KB
testcase_22 AC 169 ms
17,748 KB
testcase_23 AC 317 ms
15,672 KB
testcase_24 AC 103 ms
10,480 KB
testcase_25 AC 246 ms
13,744 KB
testcase_26 AC 288 ms
15,852 KB
testcase_27 AC 58 ms
9,224 KB
testcase_28 AC 239 ms
13,992 KB
testcase_29 AC 372 ms
17,440 KB
testcase_30 AC 252 ms
14,300 KB
testcase_31 AC 47 ms
8,800 KB
testcase_32 AC 233 ms
13,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

P,N = map(int, input().split())
A = [int(a) for a in input().split()]
S = input()

ans = A[0]
for i in range(N-1):
    if S[i] == "+":
        ans += A[i+1]
    elif S[i] == "-":
        ans -= A[i+1]
    elif S[i] == "*":
        ans *= A[i+1]
    else:
        ans *= pow(A[i+1], P-2, P)
    ans %= P
print(ans)
0