結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
7,788 KB
testcase_01 AC 83 ms
19,100 KB
testcase_02 AC 14 ms
7,788 KB
testcase_03 AC 152 ms
18,256 KB
testcase_04 AC 126 ms
16,604 KB
testcase_05 AC 128 ms
16,564 KB
testcase_06 AC 94 ms
13,952 KB
testcase_07 AC 120 ms
16,432 KB
testcase_08 AC 131 ms
17,408 KB
testcase_09 AC 121 ms
16,316 KB
testcase_10 AC 105 ms
15,160 KB
testcase_11 AC 114 ms
15,652 KB
testcase_12 AC 97 ms
13,956 KB
testcase_13 WA -
testcase_14 AC 57 ms
9,572 KB
testcase_15 AC 23 ms
8,368 KB
testcase_16 AC 45 ms
9,216 KB
testcase_17 WA -
testcase_18 AC 154 ms
17,888 KB
testcase_19 AC 98 ms
13,972 KB
testcase_20 AC 171 ms
18,176 KB
testcase_21 AC 128 ms
15,872 KB
testcase_22 AC 150 ms
17,596 KB
testcase_23 AC 285 ms
15,680 KB
testcase_24 AC 93 ms
10,572 KB
testcase_25 AC 217 ms
13,856 KB
testcase_26 AC 257 ms
15,940 KB
testcase_27 AC 52 ms
9,260 KB
testcase_28 AC 213 ms
13,968 KB
testcase_29 AC 329 ms
17,288 KB
testcase_30 AC 217 ms
14,232 KB
testcase_31 AC 41 ms
8,840 KB
testcase_32 AC 202 ms
13,364 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-=x
    elif c=='*':
        ans*=x
    else:
        ans*=pow(x,p-2,p)
    if ans<0:
        ans+=p
    if p<ans:
        ans%=p
print(ans)
0