結果

問題 No.990 N×Mマス計算(Kの倍数)
ユーザー convexineqconvexineq
提出日時 2021-05-06 06:12:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 267 ms / 2,000 ms
コード長 538 bytes
コンパイル時間 884 ms
コンパイル使用メモリ 87,184 KB
実行使用メモリ 106,136 KB
最終ジャッジ日時 2023-10-11 23:32:18
合計ジャッジ時間 4,879 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
71,364 KB
testcase_01 AC 97 ms
72,020 KB
testcase_02 AC 98 ms
71,688 KB
testcase_03 AC 97 ms
71,732 KB
testcase_04 AC 105 ms
77,328 KB
testcase_05 AC 97 ms
71,688 KB
testcase_06 AC 96 ms
71,684 KB
testcase_07 AC 97 ms
71,604 KB
testcase_08 AC 98 ms
71,560 KB
testcase_09 AC 98 ms
71,840 KB
testcase_10 AC 137 ms
86,112 KB
testcase_11 AC 157 ms
92,540 KB
testcase_12 AC 267 ms
106,136 KB
testcase_13 AC 141 ms
84,324 KB
testcase_14 AC 153 ms
96,312 KB
testcase_15 AC 132 ms
85,848 KB
testcase_16 AC 151 ms
90,128 KB
testcase_17 AC 127 ms
83,976 KB
testcase_18 AC 261 ms
105,756 KB
testcase_19 AC 177 ms
87,488 KB
testcase_20 AC 186 ms
105,416 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m,k,op,*ab = open(0).read().split()
m,k = int(m),int(k)
from collections import Counter
from math import gcd
a = map(int,ab[:m])
b = [int(i)%k for i in ab[m:]]
if op == "+":
    d = Counter(b)
    print(sum(d[-ai%k] for ai in a))
    exit()
r = []
for i in range(1,k+1):
    if i*i > k: break
    if k%i==0: r.append(i)
    if i*i != k: r.append(k//i)
da = Counter(gcd(i,k) for i in a)
db = Counter(gcd(i,k) for i in b)
ans = 0
for ai,w in da.items():
    for bi,v in db.items():
        if ai*bi%k==0:
            ans += w*v
print(ans)
0