結果

問題 No.1092 modular arithmetic
ユーザー mkawa2mkawa2
提出日時 2021-06-04 15:38:10
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 342 ms / 2,000 ms
コード長 936 bytes
コンパイル時間 275 ms
コンパイル使用メモリ 10,956 KB
実行使用メモリ 17,480 KB
最終ジャッジ日時 2023-08-12 04:04:00
合計ジャッジ時間 8,491 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,860 KB
testcase_01 AC 83 ms
17,480 KB
testcase_02 AC 16 ms
7,736 KB
testcase_03 AC 155 ms
16,828 KB
testcase_04 AC 129 ms
15,000 KB
testcase_05 AC 134 ms
15,116 KB
testcase_06 AC 100 ms
13,280 KB
testcase_07 AC 122 ms
15,160 KB
testcase_08 AC 136 ms
16,232 KB
testcase_09 AC 127 ms
14,928 KB
testcase_10 AC 109 ms
13,744 KB
testcase_11 AC 121 ms
14,448 KB
testcase_12 AC 101 ms
13,268 KB
testcase_13 AC 54 ms
9,532 KB
testcase_14 AC 63 ms
9,768 KB
testcase_15 AC 25 ms
8,560 KB
testcase_16 AC 50 ms
9,148 KB
testcase_17 AC 63 ms
9,692 KB
testcase_18 AC 158 ms
16,464 KB
testcase_19 AC 101 ms
13,040 KB
testcase_20 AC 162 ms
16,832 KB
testcase_21 AC 130 ms
14,940 KB
testcase_22 AC 152 ms
16,300 KB
testcase_23 AC 298 ms
14,628 KB
testcase_24 AC 96 ms
9,972 KB
testcase_25 AC 230 ms
13,232 KB
testcase_26 AC 268 ms
14,604 KB
testcase_27 AC 54 ms
9,248 KB
testcase_28 AC 224 ms
13,180 KB
testcase_29 AC 342 ms
16,276 KB
testcase_30 AC 257 ms
13,388 KB
testcase_31 AC 43 ms
8,832 KB
testcase_32 AC 215 ms
12,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

# sys.setrecursionlimit(200005)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.buffer.readline())
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def LI1(): return list(map(int1, sys.stdin.buffer.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def BI(): return sys.stdin.buffer.readline().rstrip()
def SI(): return sys.stdin.buffer.readline().rstrip().decode()
dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10**16
# md = 998244353
# md = 10**9+7

p, n = LI()
aa = LI()
s = SI()
ans = aa[0]
for a, c in zip(aa[1:], s):
    if c == "+": ans = (ans+a)%p
    if c == "-": ans = (ans-a)%p
    if c == "*": ans = (ans*a)%p
    if c == "/": ans = (ans*pow(a, p-2, p))%p
print(ans)
0