結果

問題 No.990 N×Mマス計算(Kの倍数)
ユーザー qibqib
提出日時 2023-04-19 03:33:03
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 557 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 125,452 KB
最終ジャッジ日時 2024-04-22 04:29:13
合計ジャッジ時間 4,895 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
58,752 KB
testcase_01 AC 42 ms
53,248 KB
testcase_02 AC 49 ms
59,520 KB
testcase_03 AC 43 ms
54,144 KB
testcase_04 AC 47 ms
60,032 KB
testcase_05 AC 44 ms
54,144 KB
testcase_06 AC 55 ms
61,184 KB
testcase_07 AC 51 ms
61,056 KB
testcase_08 AC 43 ms
54,016 KB
testcase_09 AC 42 ms
53,632 KB
testcase_10 AC 117 ms
91,392 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

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