[ICPC2020济南G] Xor Transformation - 构造

Description

给定一个X和Y,对于X每次可以选择一个A(\(0<=A<X\)),使得X = X xor A,现在要求在5步内将X变为Y,请输出操作数目,以及每步的A

Solution

先变成 x|y,再变成 y

#include <bits/stdc++.h>
using namespace std;

#define int long long

signed main()
{
    int x, y;
    cin >> x >> y;
    int z = x | y;
    cout << 2 << endl;
    cout << (x ^ z) << " " << (y ^ z) << endl;
}

相关文章:

  • 2022-12-23
  • 2021-08-02
  • 2022-12-23
  • 2022-12-23
  • 2021-07-01
  • 2021-11-16
  • 2021-07-03
猜你喜欢
  • 2022-12-23
  • 2021-07-08
  • 2021-09-16
  • 2022-12-23
  • 2021-10-15
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案