結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
61,200 KB
testcase_01 AC 35 ms
54,740 KB
testcase_02 AC 34 ms
54,928 KB
testcase_03 AC 34 ms
54,620 KB
testcase_04 AC 37 ms
61,624 KB
testcase_05 AC 34 ms
54,664 KB
testcase_06 AC 33 ms
55,328 KB
testcase_07 AC 33 ms
55,308 KB
testcase_08 AC 34 ms
54,388 KB
testcase_09 AC 35 ms
55,260 KB
testcase_10 AC 99 ms
92,092 KB
testcase_11 AC 98 ms
88,212 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

N,M,K=map(int,input().split())
B=list(input().split())
A=[int(input()) for i in range(N)]

ANS=0
from collections import Counter

if B[0]=="+":
    B=list(map(int,B[1:]))
    A=Counter([a%K for a in A])
    B=Counter([b%K for b in B])

    for c in A:
        ANS+=A[c]*B[K-c]

    print(ANS)
    sys.exit()
        
B=list(map(int,B[1:]))

import math
x=K
xr=math.ceil(math.sqrt(x))

LIST=[]
for i in range(1,xr+1):
    if x%i==0:
        LIST.append(i)
        LIST.append(x//i)

L=sorted(set(LIST),reverse=True)

SC=[0]*len(L)
for i in range(len(L)):
    l=L[i]
    for b in B:
        if b%l==0:
            SC[i]+=1

for a in A:
    for i in range(len(L)):
        l=L[i]
        if a%l==0:
            ANS+=SC[len(L)-i-1]
            break

print(ANS)

0