結果

問題 No.990 N×Mマス計算(Kの倍数)
ユーザー ryo_nryo_n
提出日時 2020-02-14 23:17:58
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 491 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 38,540 KB
最終ジャッジ日時 2024-04-27 20:17:58
合計ジャッジ時間 3,470 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
10,752 KB
testcase_01 AC 23 ms
10,624 KB
testcase_02 WA -
testcase_03 AC 25 ms
10,624 KB
testcase_04 AC 24 ms
10,624 KB
testcase_05 AC 24 ms
10,624 KB
testcase_06 RE -
testcase_07 WA -
testcase_08 AC 24 ms
10,752 KB
testcase_09 AC 23 ms
10,752 KB
testcase_10 AC 131 ms
21,684 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 AC 264 ms
20,972 KB
testcase_15 AC 197 ms
15,476 KB
testcase_16 AC 208 ms
21,832 KB
testcase_17 AC 133 ms
15,080 KB
testcase_18 RE -
testcase_19 WA -
testcase_20 AC 333 ms
38,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections

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

B_K = [x % K for x in B]
c_B_K = collections.Counter(B_K)

ans = 0

for j in range(N):
    if C[0] == '+':
        ans += c_B_K[(K - A[j] % K) % K]
    else:
        q, r = divmod(K, (A[j] % K))
        if r == 0:
            ans += c_B_K[q]
        else:
            ans += c_B_K[r + q + 1]
        ans += c_B_K[0]

print(ans)
0