版本比较
题解:CF585C Alice, Bob, Oranges and Apples
正文
增加 2 行删除 2 行
23 行未改动24252627282829303132323334353637 行未改动23 行未改动$\mathrm{solve}(n,1)=(n-1)A$。
当 $a>o$ 时,$\mathrm{solve}(o,a)= ( \lfloor \frac b a \rfloor B)(\mathrm{solve}(o,a \bmod o)A)$。
否则答案为 $\mathrm{inv}(\mathrm{solve}(a, o))$, $\mathrm{inv}(s)$ 定义为将 $s$ 串中的 $A,B$ 互换。否则答案为 $\mathrm{inv}(\mathrm{solve}(a, o))$,$\mathrm{inv}(s)$ 定义为将 $s$ 串中的 $A,B$ 互换。
观察可知其过程类似欧几里得算法,故时间复杂度为 $O(\log \max(o,a))$。
代码如下:代码如下:```cpp#include <bits/stdc++.h> using namespace std;37 行未改动