結果

問題 No.990 N×Mマス計算(Kの倍数)
ユーザー freecss00freecss00
提出日時 2020-02-14 23:28:23
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 513 bytes
コンパイル時間 258 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 27,828 KB
最終ジャッジ日時 2024-04-27 20:20:26
合計ジャッジ時間 4,499 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
17,692 KB
testcase_01 AC 29 ms
10,880 KB
testcase_02 AC 30 ms
10,880 KB
testcase_03 AC 30 ms
10,880 KB
testcase_04 AC 29 ms
10,880 KB
testcase_05 AC 30 ms
10,880 KB
testcase_06 AC 30 ms
10,752 KB
testcase_07 AC 30 ms
10,752 KB
testcase_08 AC 30 ms
10,752 KB
testcase_09 AC 30 ms
10,880 KB
testcase_10 AC 153 ms
19,184 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0