結果

問題 No.990 N×Mマス計算(Kの倍数)
ユーザー 👑 H20H20
提出日時 2021-07-15 11:46:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 243 ms / 2,000 ms
コード長 721 bytes
コンパイル時間 489 ms
コンパイル使用メモリ 87,084 KB
実行使用メモリ 111,224 KB
最終ジャッジ日時 2023-09-17 17:21:34
合計ジャッジ時間 4,517 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 98 ms
71,548 KB
testcase_01 AC 97 ms
71,612 KB
testcase_02 AC 97 ms
71,628 KB
testcase_03 AC 97 ms
71,688 KB
testcase_04 AC 98 ms
71,564 KB
testcase_05 AC 97 ms
71,796 KB
testcase_06 AC 98 ms
71,528 KB
testcase_07 AC 97 ms
71,560 KB
testcase_08 AC 95 ms
71,484 KB
testcase_09 AC 97 ms
71,580 KB
testcase_10 AC 161 ms
87,884 KB
testcase_11 AC 178 ms
92,996 KB
testcase_12 AC 243 ms
94,396 KB
testcase_13 AC 157 ms
88,108 KB
testcase_14 AC 178 ms
89,092 KB
testcase_15 AC 159 ms
83,244 KB
testcase_16 AC 183 ms
89,476 KB
testcase_17 AC 151 ms
81,940 KB
testcase_18 AC 242 ms
94,400 KB
testcase_19 AC 182 ms
86,572 KB
testcase_20 AC 229 ms
111,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections
import math

N,M,K = map(int,input().split())
B = list(input().split())
OP = B[0]
B = list(map(int, B[1:]))
A = []
for _ in range(N):
    A.append(int(input()))

ANS = 0
if OP=='+':
    for i in range(N):
        A[i] = A[i]%K
    for i in range(M):
        B[i] = B[i]%K
    CA = collections.Counter(A)
    CB = collections.Counter(B)
    for k,v in CA.items():
        ANS += CB[(K-k)%K]*v
else:
    for i in range(N):
        A[i] = math.gcd(A[i],K)
    for i in range(M):
        B[i] = math.gcd(B[i],K)
    CA = collections.Counter(A)
    CB = collections.Counter(B)
    for k1,v1 in CA.items():
        for k2,v2 in CB.items():
            if k1*k2%K==0:
                ANS += v1*v2

print(ANS)
0