結果

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

ソースコード

diff #

import collections

import fractions

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:
        if A[j] % K == 0:
            ans += M
            continue
        z = (A[j] * K) // fractions.gcd(A[j], K)
        ans += c_B_K[z // A[j]]
        ans += c_B_K[0]

print(ans)
0