結果
| 問題 | No.990 N×Mマス計算(Kの倍数) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-02-27 17:50:56 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 157 ms / 2,000 ms |
| コード長 | 591 bytes |
| 記録 | |
| コンパイル時間 | 152 ms |
| コンパイル使用メモリ | 84,864 KB |
| 実行使用メモリ | 120,320 KB |
| 最終ジャッジ日時 | 2026-04-19 02:04:28 |
| 合計ジャッジ時間 | 2,546 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 19 |
ソースコード
from collections import defaultdict
from math import gcd
N,M,K=map(int, input().split())
S=input().split()
op=S[0]
B=list(map(int,S[1:]))
A=list(int(input()) for _ in range(N))
res=0
if op=="+":
C=defaultdict(int)
for b in B:
C[b%K]+=1
for a in A:
a%=K
res+=C[(K-a)%K]
print(res)
else:
C=defaultdict(int)
D=defaultdict(int)
for a in A:
C[gcd(a,K)]+=1
for b in B:
D[gcd(b,K)]+=1
for key,val in C.items():
for key2, val2 in D.items():
if key*key2%K==0:
res+=val*val2
print(res)