UVa 12716 GCD XOR (数论+bitmask)

题目链接:

\(gcd(a,b) = a \oplus b\)
\(a \oplus b=c\) 可以写成 \(a \oplus c=b\),于是 \(c\)\(a\) 的因数

进一步可以发现,满足 \(gcd(a,b) = a \oplus b = c\) 的三元组 \((a,b,c)\) 满足 \(c = a-b\),于是枚举 \(a,c\),计算 \(b = a-c\) 即可

posted @ 2021-09-07 23:29  Tartarus_li  阅读(28)  评论(0编辑  收藏  举报