結果
| 問題 |
No.990 N×Mマス計算(Kの倍数)
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2020-02-14 22:51:40 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,196 bytes |
| コンパイル時間 | 397 ms |
| コンパイル使用メモリ | 81,980 KB |
| 実行使用メモリ | 210,700 KB |
| 最終ジャッジ日時 | 2024-11-16 01:14:39 |
| 合計ジャッジ時間 | 8,946 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 14 WA * 3 TLE * 2 |
ソースコード
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
L=int(math.sqrt(x))
FACT=dict()
for i in range(2,L+2):
while x%i==0:
FACT[i]=FACT.get(i,0)+1
x=x//i
if x!=1:
FACT[x]=FACT.get(x,0)+1
fs=list(FACT.keys())
fv=list(FACT.values())
LEN=len(fs)
from collections import defaultdict
SCA=defaultdict(int)
SCB=defaultdict(int)
for b in B:
sc=[0]*LEN
for i in range(LEN):
while b%fs[i]==0:
sc[i]+=1
b//=fs[i]
SCB[tuple(sc)]+=1
for a in A:
sc=[0]*LEN
for i in range(LEN):
while a%fs[i]==0:
sc[i]+=1
a//=fs[i]
SCA[tuple(sc)]+=1
def geq(sa,sb):
for i in range(LEN):
if fv[i]-sa[i]>sb[i]:
return 0
return 1
for sa in SCA:
for sb in SCB:
if geq(sa,sb)==1:
ANS+=SCA[sa]*SCB[sb]
print(ANS)
titia