P6610 [Code+#7] 同余方程 题解
一道关于 Legendre 符号的推式子好题。 首先引入 Legendre 符号。定义 Legendre 符号 $\dbinom{a}{p} = \begin{cases} 0 & \gcd (a,p) \ne 1 \ 1 & \gcd (a,p) = 1 \land ((\exists x \in \text Z) x^2 \equiv a \pmod p) \ -1...
一道关于 Legendre 符号的推式子好题。 首先引入 Legendre 符号。定义 Legendre 符号 $\dbinom{a}{p} = \begin{cases} 0 & \gcd (a,p) \ne 1 \ 1 & \gcd (a,p) = 1 \land ((\exists x \in \text Z) x^2 \equiv a \pmod p) \ -1...
A: 注意到只有当 $a_0 = 1 \lor a_1 = 1$ 时 $Alice$ 才能赢。
B: 注意到答案是 $\min{mex(a), k - 1}$。
C: 首先注意到最终的答案一定是一个包含了 $k$ 的区间。那么,维护变量 $a, b$,表示从 k 开始往左,右分别有多少个被占领的格子。 然后一直尝试给左边/右边加格子,直到不能加为止。<...