結果

問題 No.1092 modular arithmetic
ユーザー 👑 rin204rin204
提出日時 2020-08-13 08:23:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 433 ms / 2,000 ms
コード長 309 bytes
コンパイル時間 247 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 21,844 KB
最終ジャッジ日時 2024-04-18 01:19:31
合計ジャッジ時間 7,605 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,752 KB
testcase_01 AC 102 ms
21,844 KB
testcase_02 AC 29 ms
10,880 KB
testcase_03 AC 192 ms
20,812 KB
testcase_04 AC 161 ms
19,128 KB
testcase_05 AC 167 ms
19,044 KB
testcase_06 AC 130 ms
16,708 KB
testcase_07 AC 155 ms
19,088 KB
testcase_08 AC 170 ms
20,016 KB
testcase_09 AC 160 ms
18,672 KB
testcase_10 AC 139 ms
17,784 KB
testcase_11 AC 148 ms
18,252 KB
testcase_12 AC 130 ms
16,660 KB
testcase_13 AC 68 ms
12,160 KB
testcase_14 AC 78 ms
12,288 KB
testcase_15 AC 37 ms
11,008 KB
testcase_16 AC 66 ms
12,032 KB
testcase_17 AC 80 ms
12,376 KB
testcase_18 AC 197 ms
20,576 KB
testcase_19 AC 133 ms
16,568 KB
testcase_20 AC 205 ms
21,048 KB
testcase_21 AC 161 ms
18,564 KB
testcase_22 AC 190 ms
20,348 KB
testcase_23 AC 373 ms
18,288 KB
testcase_24 AC 131 ms
12,928 KB
testcase_25 AC 294 ms
16,504 KB
testcase_26 AC 345 ms
18,452 KB
testcase_27 AC 79 ms
11,904 KB
testcase_28 AC 289 ms
16,664 KB
testcase_29 AC 433 ms
20,140 KB
testcase_30 AC 284 ms
16,864 KB
testcase_31 AC 59 ms
11,520 KB
testcase_32 AC 262 ms
15,804 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

p, n = map(int, input().split())
alst = list(map(int, input().split()))
s = input()
ans = alst[0]

for a, ope in zip(alst[1:], s):
    if ope == "+":
        ans += a
    elif ope == "-":
        ans -= a
    elif ope == "*":
        ans *= a
    else:
        ans *= pow(a, p - 2, p)

    ans %= p
print(ans)
0