結果

問題 No.990 N×Mマス計算(Kの倍数)
ユーザー prd_xxxprd_xxx
提出日時 2020-02-14 22:44:02
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 710 bytes
コンパイル時間 301 ms
コンパイル使用メモリ 87,296 KB
実行使用メモリ 98,152 KB
最終ジャッジ日時 2023-08-10 02:14:00
合計ジャッジ時間 9,323 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 98 ms
71,472 KB
testcase_01 AC 95 ms
71,264 KB
testcase_02 AC 92 ms
71,316 KB
testcase_03 AC 92 ms
71,476 KB
testcase_04 AC 104 ms
76,628 KB
testcase_05 AC 93 ms
71,392 KB
testcase_06 AC 93 ms
71,376 KB
testcase_07 AC 93 ms
71,300 KB
testcase_08 AC 91 ms
71,528 KB
testcase_09 AC 92 ms
71,424 KB
testcase_10 AC 137 ms
84,640 KB
testcase_11 AC 141 ms
88,072 KB
testcase_12 TLE -
testcase_13 AC 128 ms
83,540 KB
testcase_14 AC 138 ms
85,332 KB
testcase_15 AC 123 ms
80,272 KB
testcase_16 AC 141 ms
85,900 KB
testcase_17 AC 121 ms
79,940 KB
testcase_18 TLE -
testcase_19 AC 1,372 ms
83,472 KB
testcase_20 AC 172 ms
98,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
N,M,K = map(int,input().split())
op,*B = input().split()
A = [int(input()) for i in range(N)]
B = [int(b) for b in B]

from collections import Counter
ans = 0
if op=='+':
    c = Counter()
    for a in A:
        c[a%K] += 1
    for b in B:
        ans += c[(K-b%K)%K]
else:
    ds = set()
    m = 1
    while m*m <= K:
        if K%m==0:
            ds.add(m)
            ds.add(K//m)
        m += 1
    ds = sorted(list(ds), reverse=True)
    c = Counter()
    for a in A:
        for d in ds:
            if a%d==0:
                c[d] += 1
                break
    for b in B:
        for d in ds:
            if (b*d)%K == 0:
                ans += c[d]

print(ans)
0