結果

問題 No.1092 modular arithmetic
ユーザー first_vilfirst_vil
提出日時 2020-06-25 10:20:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 330 ms / 2,000 ms
コード長 278 bytes
コンパイル時間 72 ms
コンパイル使用メモリ 10,608 KB
実行使用メモリ 19,232 KB
最終ジャッジ日時 2023-09-16 21:49:39
合計ジャッジ時間 5,626 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,864 KB
testcase_01 AC 83 ms
19,232 KB
testcase_02 AC 15 ms
7,952 KB
testcase_03 AC 153 ms
18,328 KB
testcase_04 AC 118 ms
16,476 KB
testcase_05 AC 123 ms
16,424 KB
testcase_06 AC 94 ms
14,040 KB
testcase_07 AC 117 ms
16,508 KB
testcase_08 AC 127 ms
17,328 KB
testcase_09 AC 114 ms
16,236 KB
testcase_10 AC 100 ms
14,764 KB
testcase_11 AC 114 ms
15,696 KB
testcase_12 AC 94 ms
13,956 KB
testcase_13 AC 48 ms
9,268 KB
testcase_14 AC 53 ms
9,532 KB
testcase_15 AC 22 ms
8,416 KB
testcase_16 AC 41 ms
9,208 KB
testcase_17 AC 54 ms
9,668 KB
testcase_18 AC 143 ms
17,896 KB
testcase_19 AC 92 ms
13,836 KB
testcase_20 AC 150 ms
18,356 KB
testcase_21 AC 119 ms
16,048 KB
testcase_22 AC 148 ms
17,708 KB
testcase_23 AC 285 ms
15,600 KB
testcase_24 AC 92 ms
10,384 KB
testcase_25 AC 222 ms
13,900 KB
testcase_26 AC 253 ms
16,008 KB
testcase_27 AC 52 ms
9,324 KB
testcase_28 AC 218 ms
13,964 KB
testcase_29 AC 330 ms
17,316 KB
testcase_30 AC 223 ms
14,088 KB
testcase_31 AC 43 ms
8,888 KB
testcase_32 AC 207 ms
13,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

p,n=map(int,input().split())
a=list(map(int,input().split()))
ans=a[0]
s=input()
for x,c in zip(a[1:],s):
    if c=='+':
        ans+=x
    elif c=='-':
        ans+=p-x
    elif c=='*':
        ans*=x
    else:
        ans*=pow(x,p-2,p)
    if p<=ans:
        ans%=p
print(ans)
0