結果

問題 No.990 N×Mマス計算(Kの倍数)
ユーザー ryo_n
提出日時 2020-02-14 23:17:58
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 491 bytes
コンパイル時間 224 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 38,472 KB
最終ジャッジ日時 2024-11-16 01:38:17
合計ジャッジ時間 4,142 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 11 WA * 3 RE * 5
権限があれば一括ダウンロードができます

ソースコード

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