結果

問題 No.990 N×Mマス計算(Kの倍数)
ユーザー prd_xxxprd_xxx
提出日時 2020-02-14 22:53:19
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 868 bytes
コンパイル時間 209 ms
コンパイル使用メモリ 81,828 KB
実行使用メモリ 96,672 KB
最終ジャッジ日時 2024-04-27 20:03:15
合計ジャッジ時間 8,213 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
54,452 KB
testcase_01 AC 33 ms
53,772 KB
testcase_02 AC 34 ms
55,240 KB
testcase_03 AC 33 ms
53,668 KB
testcase_04 AC 36 ms
60,408 KB
testcase_05 AC 33 ms
53,936 KB
testcase_06 AC 32 ms
54,724 KB
testcase_07 AC 37 ms
54,300 KB
testcase_08 AC 40 ms
55,100 KB
testcase_09 AC 34 ms
55,268 KB
testcase_10 AC 71 ms
84,032 KB
testcase_11 AC 78 ms
87,696 KB
testcase_12 AC 1,977 ms
89,380 KB
testcase_13 AC 73 ms
83,140 KB
testcase_14 AC 78 ms
84,692 KB
testcase_15 AC 65 ms
79,044 KB
testcase_16 AC 79 ms
83,880 KB
testcase_17 AC 64 ms
79,008 KB
testcase_18 AC 1,967 ms
89,184 KB
testcase_19 TLE -
testcase_20 AC 111 ms
96,672 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)
    ca = Counter()
    for a in A:
        for d in ds:
            if a%d==0:
                ca[d] += 1
                break
    cb = Counter()
    for b in B:
        for d in ds:
            if b%d==0:
                cb[d] += 1
                break
    for ka,va in ca.items():
        for kb,vb in cb.items():
            if (ka*kb)%K == 0:
                ans += va*vb

print(ans)
0