原题链接
考察:构造
思路:
??异或和为u,数值和为v.如何判断不可能成立?
#include <iostream>
#include <cstring>
using namespace std;
typedef long long LL;
LL n,m;
void solve()
{
if(!m) {puts("0");return;}
if(n==m) {printf("%d\n%lld\n",1,n);return;}
if(n>m||n%2!=m%2) {printf("%d\n",-1);return;}
LL d = m-n>>1ll;
if(!(d&n)) printf("%d\n%lld %lld\n",2,d,n+d);
else printf("%d\n%lld %lld %lld\n",3,d,d,n);
}
int main()
{
scanf("%lld%lld",&n,&m);
solve();
return 0;
}
Ehab the Xorcist CodeForces - 1325D
原文:https://www.cnblogs.com/newblg/p/14800724.html