結果

問題 No.988 N×Mマス計算(総和)
ユーザー ngng628ngng628
提出日時 2020-04-09 23:51:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 227 ms / 2,000 ms
コード長 371 bytes
コンパイル時間 76 ms
コンパイル使用メモリ 10,532 KB
実行使用メモリ 23,280 KB
最終ジャッジ日時 2023-09-20 12:21:24
合計ジャッジ時間 2,747 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,812 KB
testcase_01 AC 15 ms
7,896 KB
testcase_02 AC 16 ms
7,876 KB
testcase_03 AC 17 ms
7,800 KB
testcase_04 AC 16 ms
7,960 KB
testcase_05 AC 15 ms
7,892 KB
testcase_06 AC 16 ms
7,956 KB
testcase_07 AC 16 ms
7,864 KB
testcase_08 AC 15 ms
7,804 KB
testcase_09 AC 16 ms
7,796 KB
testcase_10 AC 92 ms
12,340 KB
testcase_11 AC 77 ms
19,116 KB
testcase_12 AC 179 ms
21,192 KB
testcase_13 AC 63 ms
15,208 KB
testcase_14 AC 69 ms
15,160 KB
testcase_15 AC 116 ms
10,688 KB
testcase_16 AC 153 ms
17,496 KB
testcase_17 AC 184 ms
19,872 KB
testcase_18 AC 73 ms
17,952 KB
testcase_19 AC 149 ms
20,020 KB
testcase_20 AC 227 ms
23,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M, K = map(int, input().split())
line2 = input().split()
op = line2[0]
B = [int(x) for x in line2[1:]]
A = [int(input()) for _ in range(N)]

ans = 0
if op == '+':
    a_sum = (sum(A) % K)*M % K
    b_sum = (sum(B) % K)*N % K
    ans = (a_sum + b_sum) % K

else: # op == '*'
    a_sum = sum(A) % K
    for b in B:
        ans = (ans + a_sum*b % K) % K

print(ans)
    
0