結果

問題 No.990 N×Mマス計算(Kの倍数)
ユーザー brthyyjpbrthyyjp
提出日時 2020-02-14 22:04:48
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,156 bytes
コンパイル時間 148 ms
コンパイル使用メモリ 82,224 KB
実行使用メモリ 118,876 KB
最終ジャッジ日時 2024-04-27 19:40:20
合計ジャッジ時間 5,624 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
59,996 KB
testcase_01 AC 40 ms
52,600 KB
testcase_02 AC 47 ms
59,536 KB
testcase_03 WA -
testcase_04 AC 873 ms
59,244 KB
testcase_05 WA -
testcase_06 AC 39 ms
52,744 KB
testcase_07 AC 46 ms
59,768 KB
testcase_08 WA -
testcase_09 AC 46 ms
58,732 KB
testcase_10 WA -
testcase_11 AC 114 ms
94,212 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 = 13-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