题意
max
x
b
T
x
s
.
t
.
x
T
A
x
−
1
≤
0
\begin{aligned} \max_x &\quad b^Tx\\ {\rm s.t.} &\quad x^TAx-1\le0 \end{aligned}
xmaxs.t.bTxxTAx−1≤0
求
(
b
T
x
)
2
m
o
d
998244353
(b^Tx)^2\mod 998244353
(bTx)2mod998244353.
A
A
A为
n
×
n
n\times n
n×n的对称矩阵,
b
,
x
∈
R
n
b,x\in\mathbb{R}^n
b,x∈Rn
n
≤
200
,
0
≤
∣
A
i
,
j
∣
,
∣
b
i
∣
≤
1
0
9
n\le200,0\le|A_{i,j}|,|b_i|\le10^9
n≤200,0≤∣Ai,j∣,∣bi∣≤109
∀
x
∈
R
n
/
{
0
}
,
x
T
A
x
>
0
\forall x\in\mathbb{R}^n/\ \{\boldsymbol0\},x^TAx>0
∀x∈Rn/ {0},xTAx>0
det
(
A
)
≢
0
(
m
o
d
998244353
)
\det(A)\not\equiv0\pmod{998244353}
det(A)≡0(mod998244353)
题解
设兰格朗日函数
L
(
x
,
λ
)
=
b
T
x
+
λ
(
x
T
A
x
−
1
)
\mathcal{L}(x,\lambda)=b^Tx+\lambda(x^TAx-1)
L(x,λ)=bTx+λ(xTAx−1),根据向量求导法则,有
∂
L
∂
x
=
b
+
λ
(
A
+
A
T
)
x
=
b
+
2
λ
A
x
\frac{\partial\mathcal{L}}{\partial x}=b+\lambda(A+A^T)x=b+2\lambda Ax
∂x∂L=b+λ(A+AT)x=b+2λAx
令
∂
L
∂
x
=
0
\displaystyle\frac{\partial\mathcal{L}}{\partial x}=0
∂x∂L=0,可得
x
=
−
A
−
1
b
2
λ
\displaystyle x=-\frac{A^{-1}b}{2\lambda}
x=−2λA−1b。由KKT条件:
λ
(
x
T
A
x
−
1
)
=
0
,
λ
≤
0
\lambda(x^TAx-1)=0,\lambda\le0
λ(xTAx−1)=0,λ≤0。将
x
x
x带入得
λ
[
(
−
A
−
1
b
2
λ
)
T
A
(
−
A
−
1
b
2
λ
)
−
1
]
=
0
⇒
b
T
(
A
−
1
)
T
A
A
−
1
b
=
4
λ
2
,
(
A
−
1
)
T
=
A
−
1
⇒
λ
=
−
1
2
b
T
A
−
1
b
\begin{aligned} &\lambda[(-\frac{A^{-1}b}{2\lambda})^TA(-\frac{A^{-1}b}{2\lambda})-1]=0\\ \Rightarrow&\qquad b^T(A^{-1})^TAA^{-1}b=4\lambda^2,\quad (A^{-1})^T=A^{-1}\\ \Rightarrow&\qquad \lambda=-\frac12\sqrt{b^TA^{-1}b} \end{aligned}
⇒⇒λ[(−2λA−1b)TA(−2λA−1b)−1]=0bT(A−1)TAA−1b=4λ2,(A−1)T=A−1λ=−21bTA−1b
故
b
T
x
=
b
T
(
−
A
−
1
b
2
λ
)
=
−
b
T
A
−
1
b
b
T
A
−
1
b
=
b
T
A
−
1
b
b^Tx=b^T(-\frac{A^{-1}b}{2\lambda})=-\frac{b^TA^{-1}b}{\sqrt{b^TA^{-1}b}}=\sqrt{b^TA^{-1}b}
bTx=bT(−2λA−1b)=−bTA−1bbTA−1b=bTA−1b
最终的答案为
(
b
T
x
)
2
=
b
T
A
−
1
b
(b^Tx)^2=b^TA^{-1}b
(bTx)2=bTA−1b。用高斯消元求出
A
A
A的逆再相乘即可。
单组数据时间复杂度 O ( n 3 ) O(n^3) O(n3)