結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
59,008 KB
testcase_01 AC 33 ms
51,968 KB
testcase_02 AC 34 ms
52,224 KB
testcase_03 AC 37 ms
53,760 KB
testcase_04 AC 38 ms
58,368 KB
testcase_05 AC 37 ms
53,632 KB
testcase_06 AC 34 ms
52,352 KB
testcase_07 AC 34 ms
52,352 KB
testcase_08 AC 36 ms
53,760 KB
testcase_09 AC 40 ms
54,016 KB
testcase_10 AC 86 ms
91,536 KB
testcase_11 AC 73 ms
87,272 KB
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

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

ANS=0

if B[0]=="+":
    from collections import Counter
    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)

LEN=len(L)

SC=[0]*LEN
for i in range(LEN):
    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[i]
        if a%l==0:
            ANS+=SC[LEN-i-1]
            break

print(ANS)

0