結果

問題 No.1092 modular arithmetic
ユーザー brthyyjpbrthyyjp
提出日時 2020-10-13 09:53:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 316 bytes
コンパイル時間 852 ms
コンパイル使用メモリ 87,280 KB
実行使用メモリ 91,644 KB
最終ジャッジ日時 2023-09-27 23:59:57
合計ジャッジ時間 8,042 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
71,408 KB
testcase_01 AC 87 ms
91,588 KB
testcase_02 AC 62 ms
71,168 KB
testcase_03 AC 108 ms
91,600 KB
testcase_04 AC 101 ms
87,928 KB
testcase_05 AC 98 ms
87,684 KB
testcase_06 AC 89 ms
83,716 KB
testcase_07 AC 97 ms
87,768 KB
testcase_08 AC 100 ms
89,372 KB
testcase_09 AC 97 ms
87,556 KB
testcase_10 AC 94 ms
85,156 KB
testcase_11 AC 99 ms
86,420 KB
testcase_12 AC 96 ms
83,808 KB
testcase_13 AC 82 ms
84,916 KB
testcase_14 AC 84 ms
87,612 KB
testcase_15 AC 71 ms
76,948 KB
testcase_16 AC 83 ms
83,356 KB
testcase_17 AC 86 ms
87,424 KB
testcase_18 AC 110 ms
90,168 KB
testcase_19 AC 93 ms
83,612 KB
testcase_20 AC 109 ms
91,644 KB
testcase_21 AC 102 ms
86,360 KB
testcase_22 AC 104 ms
89,624 KB
testcase_23 AC 125 ms
86,088 KB
testcase_24 AC 82 ms
77,916 KB
testcase_25 AC 109 ms
83,812 KB
testcase_26 AC 119 ms
86,212 KB
testcase_27 AC 75 ms
76,600 KB
testcase_28 AC 113 ms
83,608 KB
testcase_29 AC 144 ms
89,348 KB
testcase_30 AC 114 ms
83,520 KB
testcase_31 AC 72 ms
76,716 KB
testcase_32 AC 112 ms
82,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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