結果

問題 No.1092 modular arithmetic
ユーザー trineutrontrineutron
提出日時 2020-06-24 07:18:13
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 363 ms / 2,000 ms
コード長 324 bytes
コンパイル時間 803 ms
コンパイル使用メモリ 10,756 KB
実行使用メモリ 19,092 KB
最終ジャッジ日時 2023-09-16 20:47:04
合計ジャッジ時間 6,422 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,748 KB
testcase_01 AC 104 ms
19,092 KB
testcase_02 AC 15 ms
7,780 KB
testcase_03 AC 165 ms
18,192 KB
testcase_04 AC 138 ms
16,476 KB
testcase_05 AC 143 ms
16,468 KB
testcase_06 AC 106 ms
13,972 KB
testcase_07 AC 134 ms
16,444 KB
testcase_08 AC 144 ms
17,456 KB
testcase_09 AC 132 ms
16,264 KB
testcase_10 AC 115 ms
14,848 KB
testcase_11 AC 130 ms
15,784 KB
testcase_12 AC 109 ms
13,928 KB
testcase_13 AC 63 ms
9,176 KB
testcase_14 AC 69 ms
9,592 KB
testcase_15 AC 27 ms
8,504 KB
testcase_16 AC 55 ms
9,044 KB
testcase_17 AC 70 ms
9,656 KB
testcase_18 AC 170 ms
17,968 KB
testcase_19 AC 108 ms
13,896 KB
testcase_20 AC 172 ms
18,220 KB
testcase_21 AC 136 ms
15,960 KB
testcase_22 AC 164 ms
17,628 KB
testcase_23 AC 315 ms
15,608 KB
testcase_24 AC 100 ms
10,480 KB
testcase_25 AC 243 ms
13,852 KB
testcase_26 AC 291 ms
15,964 KB
testcase_27 AC 57 ms
9,224 KB
testcase_28 AC 236 ms
13,872 KB
testcase_29 AC 363 ms
17,340 KB
testcase_30 AC 249 ms
14,120 KB
testcase_31 AC 45 ms
8,928 KB
testcase_32 AC 223 ms
13,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

p, n = map(int, input().split())
a = list(map(int, 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