結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
54,640 KB
testcase_01 AC 35 ms
54,068 KB
testcase_02 AC 35 ms
55,260 KB
testcase_03 AC 34 ms
54,116 KB
testcase_04 AC 34 ms
54,412 KB
testcase_05 AC 35 ms
54,132 KB
testcase_06 AC 36 ms
54,728 KB
testcase_07 AC 34 ms
55,516 KB
testcase_08 AC 34 ms
53,928 KB
testcase_09 AC 37 ms
54,544 KB
testcase_10 AC 79 ms
91,508 KB
testcase_11 AC 92 ms
93,108 KB
testcase_12 AC 256 ms
95,088 KB
testcase_13 AC 74 ms
87,944 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 96 ms
88,628 KB
testcase_17 WA -
testcase_18 AC 257 ms
95,348 KB
testcase_19 AC 119 ms
86,348 KB
testcase_20 AC 132 ms
102,688 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:
                R += d[c]*d2[e]
    print(R)
0