結果

問題 No.990 N×Mマス計算(Kの倍数)
ユーザー nehan_der_thalnehan_der_thal
提出日時 2020-02-28 04:14:47
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 877 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 81,804 KB
実行使用メモリ 102,340 KB
最終ジャッジ日時 2024-04-27 21:39:32
合計ジャッジ時間 2,954 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
55,288 KB
testcase_01 AC 35 ms
54,416 KB
testcase_02 AC 35 ms
55,408 KB
testcase_03 AC 39 ms
54,976 KB
testcase_04 AC 35 ms
54,648 KB
testcase_05 AC 33 ms
55,564 KB
testcase_06 AC 33 ms
54,240 KB
testcase_07 AC 39 ms
54,736 KB
testcase_08 AC 40 ms
54,276 KB
testcase_09 AC 34 ms
54,676 KB
testcase_10 AC 85 ms
91,220 KB
testcase_11 AC 91 ms
93,108 KB
testcase_12 AC 260 ms
95,216 KB
testcase_13 AC 79 ms
87,672 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 100 ms
88,792 KB
testcase_17 WA -
testcase_18 AC 268 ms
95,140 KB
testcase_19 AC 121 ms
86,328 KB
testcase_20 AC 128 ms
102,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
from collections import defaultdict
from math import gcd
N, M, K = map(int, input().split())
R = 0

bs = []
fs = []
for i in range(N+1):
    if i == 0:
        X = input().split()
        e = X[0] == '+'
        if e:
            d = defaultdict(int)
            for x in X[1:]:
                d[K-int(x)%K] += 1
        else:
            bs = list(map(int, X[1:]))
            d = defaultdict(int)
            for b in bs:
                b = gcd(b, K)
                d[b] += 1
        continue
    x = int(input())
    if e:
        R += d[x%K]
    else:
        fs.append(x)
if e:
    print(R)
else:
    d2 = defaultdict(int)
    for b in fs:
        b = gcd(b, K)
        d2[b] += 1
    for c in d:
        for e in d2:
#            print(c, e, d[c])
            if gcd(c*e, K) % K == 0:
                R += d[c]*d2[e]
    print(R)
0