标签:code amp pac int c++ out for include 题意
异或后值为 u,相加后和为 v 的最短序列。
由异或性质得初始序列为 u , (v-u)/2 , (v-u)/2 ,之后即为特判或尝试相加缩短。
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ll u,v;cin>>u>>v; ll a=u,b=(v-u)/2; if(u==0&&v==0){ cout<<"0"; }else if(v<u||(v-u)%2){ cout<<"-1"; }else if(u==v){ cout<<"1\n"; cout<<a<<endl; }else if(((a+b)^b)==u){ cout<<"2\n"; cout<<a+b<<‘ ‘<<b<<endl; }else{ cout<<"3\n"; cout<<a<<‘ ‘<<b<<‘ ‘<<b<<endl; } return 0; }
Codeforces Round #628 (Div. 2) D. Ehab the Xorcist(异或,思维题)
标签:code amp pac int c++ out for include 题意
原文地址:https://www.cnblogs.com/Kanoon/p/12495687.html