結果
| 問題 |
No.990 N×Mマス計算(Kの倍数)
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2020-02-14 22:59:01 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,212 bytes |
| コンパイル時間 | 443 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 64,140 KB |
| 最終ジャッジ日時 | 2024-11-16 01:19:16 |
| 合計ジャッジ時間 | 9,786 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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):
f=fs[i]
while b%f==0:
sc[i]+=1
b//=f
SCB[tuple(sc)]+=1
for a in A:
sc=[0]*LEN
for i in range(LEN):
f=fs[i]
while a%f==0:
sc[i]+=1
a//=f
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