結果

問題 No.1092 modular arithmetic
ユーザー Konton7Konton7
提出日時 2020-06-26 21:54:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 359 ms / 2,000 ms
コード長 377 bytes
コンパイル時間 151 ms
コンパイル使用メモリ 10,556 KB
実行使用メモリ 19,216 KB
最終ジャッジ日時 2023-09-18 04:18:19
合計ジャッジ時間 8,150 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,812 KB
testcase_01 AC 98 ms
19,216 KB
testcase_02 AC 16 ms
7,824 KB
testcase_03 AC 167 ms
18,348 KB
testcase_04 AC 145 ms
16,556 KB
testcase_05 AC 147 ms
16,616 KB
testcase_06 AC 108 ms
13,936 KB
testcase_07 AC 135 ms
16,440 KB
testcase_08 AC 151 ms
17,492 KB
testcase_09 AC 138 ms
16,100 KB
testcase_10 AC 118 ms
15,008 KB
testcase_11 AC 131 ms
15,784 KB
testcase_12 AC 112 ms
13,776 KB
testcase_13 AC 64 ms
9,144 KB
testcase_14 AC 72 ms
9,648 KB
testcase_15 AC 27 ms
8,416 KB
testcase_16 AC 58 ms
9,236 KB
testcase_17 AC 74 ms
9,576 KB
testcase_18 AC 171 ms
18,024 KB
testcase_19 AC 111 ms
13,976 KB
testcase_20 AC 178 ms
18,392 KB
testcase_21 AC 140 ms
16,028 KB
testcase_22 AC 167 ms
17,512 KB
testcase_23 AC 316 ms
15,836 KB
testcase_24 AC 102 ms
10,444 KB
testcase_25 AC 242 ms
13,824 KB
testcase_26 AC 282 ms
15,844 KB
testcase_27 AC 57 ms
9,396 KB
testcase_28 AC 234 ms
13,908 KB
testcase_29 AC 359 ms
17,440 KB
testcase_30 AC 245 ms
14,180 KB
testcase_31 AC 45 ms
8,860 KB
testcase_32 AC 224 ms
13,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

p, n = [int(v) for v in input().split()]
a = [int(v) for v in input().split()]
ans = a[0]
op = input()
for i, v in enumerate(op):
    if v == "+":
        ans += a[i+1]
        ans %= p
    if v == "-":
        ans -= a[i+1]
        ans %= p
    if v == "*":
        ans *= a[i+1]
        ans %= p
    if v == "/":
        ans *= pow(a[i+1], p-2, p)
        ans %= p
print(ans)
0