結果
| 問題 | No.990 N×Mマス計算(Kの倍数) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-02-14 23:28:23 |
| 言語 | Python3 (3.14.3 + numpy 2.4.4 + scipy 1.17.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 513 bytes |
| 記録 | |
| コンパイル時間 | 590 ms |
| コンパイル使用メモリ | 20,696 KB |
| 実行使用メモリ | 30,144 KB |
| 最終ジャッジ日時 | 2026-05-11 05:27:42 |
| 合計ジャッジ時間 | 6,123 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 9 TLE * 1 -- * 9 |
ソースコード
import math
from collections import Counter
n, m, k = map(int, input().split())
line = input().split()
op = line[0]
B = list(map(int, line[1:]))
A = [int(input()) for _ in range(n)]
if op == '+':
mod = [a % k for a in A]
modcnt = Counter(mod)
ans = sum([modcnt[(k - (b%k)) % k] for b in B])
else:
gcda = [math.gcd(k,a) for a in A]
gcdb = [math.gcd(k,b) for b in B]
ans = 0
for ga in gcda:
for gb in gcdb:
if (ga * gb) % k == 0:
ans += 1
print(ans)