結果
| 問題 |
No.990 N×Mマス計算(Kの倍数)
|
| コンテスト | |
| ユーザー |
ryo_n
|
| 提出日時 | 2020-02-15 00:46:23 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 692 bytes |
| コンパイル時間 | 93 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 38,460 KB |
| 最終ジャッジ日時 | 2024-11-16 02:07:42 |
| 合計ジャッジ時間 | 4,964 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 16 WA * 3 |
ソースコード
import collections
import math
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 = []
A_K = []
c_B_K = None
c_A_K = None
if C[0] == '+':
B_K = [x % K for x in B]
c_B_K = collections.Counter(B_K)
else:
B_K = [math.gcd(x, K) for x in B]
A_K = [math.gcd(x, K) for x in A]
c_B_K = collections.Counter(B_K)
c_A_K = collections.Counter(A_K)
ans = 0
if C[0] == '+':
for j in range(N):
ans += c_B_K[K - A[j] % K]
else:
for b in c_B_K.keys():
for a in c_A_K.keys():
if (a * b) % K == 0:
ans += c_B_K[b] * c_A_K[a]
print(ans)
ryo_n