跳到正文

题解

题解:P17569 「FAOI-R15」XOR and Ugly Equation

喵仔牛奶约 1 分钟
原文
文章信息与版本

文章信息

发布
2026年10月2日
收录
2026年10月3日
更新
2026年11月17日
篇幅
约 1 分钟
获赞
1
题目
P17569

版本

  1. v1当前

容易发现如果 aa 是奇数无解。

考虑已经求出了  mod  2k\bmod\ 2^k 的解,如何求出  mod  2k+1\bmod\ 2^{k+1} 的解。设新的解为 x+tx+t,其中 t∈{0,2k}t\in\{0,2^k\}。

方程左式为 (x+t)2⊕(x+t)=(x2+2xt+t2)⊕(x+t)(x+t)^2\oplus(x+t)=(x^2+2xt+t^2)\oplus(x+t),当 k≥1k\ge 1 时有 2t≡t2≡0(mod2k+1)2t\equiv t^2\equiv 0\pmod{2^{k+1}},因此方程化简为 x2⊕x⊕t≡a(mod2k+1)x^2\oplus x\oplus t\equiv a\pmod{2^{k+1}},可以唯一确定 tt。

枚举解  mod  2\bmod\ 2 是 00 还是 11 即可。复杂度 O(Tlog⁡a)\mathcal O(T\log a)。

原文