結果

問題 No.990 N×Mマス計算(Kの倍数)
ユーザー titiatitia
提出日時 2020-02-14 22:01:03
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 771 bytes
コンパイル時間 124 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 33,552 KB
最終ジャッジ日時 2024-04-27 19:39:04
合計ジャッジ時間 4,311 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
17,824 KB
testcase_01 AC 24 ms
11,008 KB
testcase_02 AC 25 ms
11,008 KB
testcase_03 AC 25 ms
11,008 KB
testcase_04 AC 26 ms
11,008 KB
testcase_05 AC 24 ms
10,880 KB
testcase_06 AC 24 ms
11,008 KB
testcase_07 AC 24 ms
11,008 KB
testcase_08 AC 23 ms
11,008 KB
testcase_09 AC 24 ms
11,008 KB
testcase_10 AC 130 ms
19,452 KB
testcase_11 AC 194 ms
20,472 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