結果

問題 No.990 N×Mマス計算(Kの倍数)
ユーザー qib
提出日時 2023-04-19 03:33:03
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 557 bytes
コンパイル時間 467 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 121,356 KB
最終ジャッジ日時 2024-10-14 03:32:20
合計ジャッジ時間 5,144 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 9 TLE * 1 -- * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
import math

n, m, k = map(int, input().split())
op, *b = list(input().split())

cnt = defaultdict(int)
ans = 0
if op == "+":
  for x in b:
    cnt[int(x) % k] += 1

  for _ in range(n):
    ai = int(input())
    ans += cnt[(- ai) % k]
elif op == "*":
  for x in b:
    x = int(x)
    for d in range(1, int(math.sqrt(x)) + 1):
      if x % d == 0:
        if d != x // d:
          cnt[x // d] += 1
        cnt[d] += 1

  for _ in range(n):
    ai = int(input())
    x = k // math.gcd(ai, k)
    ans += cnt[x]

print(ans)
0