MianKing has one integer XX, he wants to perform some operations to transform XX to YY (Y<X)(Y<X).
In each operation, MianKing can choose one integer 0\leq A<X0≤A<X and let X=XxorAX=X xor A.
It’s noticed that after an operation, the upper bound of AA will change because XX has changed.
Now you need to help MianKing to find a way to transform XX to YY by doing at most 5 operations.
题意描述:把一个数通过在五步以内的异或操作得到另一个数.
做法:一个数与一个数连续异或两次就可得到原数。就可以根据这个规律将数进行分类处理。若是两个数异或比原数大则运行两步,先异或y,在异或x.若是比原数小则直接与(x^y)进行异或。
#include<stdio.h>
#define ll long long
ll x, y;
int main()
{
scanf("%lld%lld",&x,&y);
if((x ^ y) > x)
{
puts("2");
printf("%lld %lld", y, x);
}
else
{
puts("1");
printf("%lld\n", x ^ y);
}
return 0;
}