XOR

ABC261E - Many Operations

考え方 回答例 考え方2進数で30桁に制限されている.bitの桁ごとに演算すれば良い.また, 1〜iまでの操作の合成 (※1) 1〜iまでの操作の合成を値に作用させた結果 を保持できれば良い.※1:bitの桁ごとに計算して,桁の計算後が終われば捨てることにすれば,…

ABC238D - AND and SUM

考え方 回答例 考え方桁ごとに考えて,繰り上がりのない$(0,1), (1,0)$の桁と,繰り上がりのある$(1,1)$の桁に分ければ,次の式が成り立つ:\begin{aligned} x + y = \underbrace{(x \mathrm{\,XOR\,} y)}_{\text{繰り上がりなし}} + \underbrace{2 \times (…

ABC236D - Dance

考え方 回答例 考え方最大で$2N = 16$人.ペアの組み方は\begin{aligned} 15!! &= 15\times 13 \times \cdots \times 3 \times 1 \\ &=2,027,025 \end{aligned}となる(例えば以下のコード).よって,全探索できる. ans = 1 x = 15 while x > 0: ans *= x …