結果

問題 No.990 N×Mマス計算(Kの倍数)
ユーザー brthyyjpbrthyyjp
提出日時 2020-02-14 22:09:25
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,155 bytes
コンパイル時間 159 ms
コンパイル使用メモリ 82,120 KB
実行使用メモリ 119,252 KB
最終ジャッジ日時 2024-04-27 19:42:28
合計ジャッジ時間 5,208 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
59,280 KB
testcase_01 AC 31 ms
52,632 KB
testcase_02 AC 38 ms
60,292 KB
testcase_03 AC 34 ms
59,264 KB
testcase_04 AC 760 ms
58,856 KB
testcase_05 AC 38 ms
58,888 KB
testcase_06 AC 33 ms
53,068 KB
testcase_07 AC 37 ms
61,300 KB
testcase_08 AC 34 ms
57,780 KB
testcase_09 AC 40 ms
58,592 KB
testcase_10 AC 193 ms
88,152 KB
testcase_11 AC 97 ms
93,764 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n, m, k = map(int, input().split())
l = list(map(str, input().split()))
b = [int(l[i]) for i in range(1, m+1)]

op = l[0]
#print(op)
#rint(b)

a = [0]*n
for i in range(n):
    a[i] = int(input())

da = {}
for i in range(n):
    if a[i]%k not in da:
        da[a[i]%k] = 1
    else:
        da[a[i]%k] += 1

db = {}
for i in range(m):
    if b[i]%k not in db:
        db[b[i]%k] = 1
    else:
        db[b[i]%k] += 1

#print(da)
#print(db)

if op == '+':
    ans = 0
    for i in range(k):
        if i not in da:
            continue
        else:
            if i == 0:
                j = 0
            else:
                j = k-i
            if j in db:
                ans += da[i]*db[j]
else:
    ans = 0
    for i in range(1, k):
        if i not in da:
            continue
        for j in range(1, k):
            if j not in db:
                continue
            if (i * j)%k == 0:
                ans += da[i]*db[j]
    if 0 in da and 0 in db:
        ans += da[0]*m + db[0]*n - da[0]*db[0]
    elif 0 in da and 0 not in db:
        ans += da[0]*m
    elif 0 not in da and 0 in db:
        ans += db[0]*n
    else:
        pass
print(ans)
0