企业网站建设情况,网站综合排名信息查询,中国能源建设集团有限公司官网,今天最新生猪价格或许更好的阅读体验
Ehab the Xorcist
思路
刚看时确实是一脸懵#xff0c;最怕的就是这种构造题了#xff0c;然后细想好像能写啊。
判断不可行的条件#xff0c;只有两种情况#xff1a;
一、vuv uvu是一定不可能的#xff0c;一串数的异或值一定小于…或许更好的阅读体验
Ehab the Xorcist
思路
刚看时确实是一脸懵最怕的就是这种构造题了然后细想好像能写啊。
判断不可行的条件只有两种情况
一、vuv uvu是一定不可能的一串数的异或值一定小于其数串的和。二、当u是奇数时数串中一定存在奇数个奇数所以整体的和一定是奇数当u时偶数时如果存在奇数那么一定是偶数个奇数所以整体的和一定是偶数。
到了这里两种不可行的情况就考虑完了 n接下来我们考虑可行的方案
假设vuv uvu当v0v 0v0的时候直接输出0当v!0v ! 0v!0的时候就是1\nv\n即可。我们考虑下一种情况的最小串的情况我们约定temp (u - v) 1一定可以构造出temp∣temp∣vtemp | temp | vtemp∣temp∣v是符合要求的。但是我们要考虑其值最小我们想想还有没有可能得到n2n 2n2的情况当然是存在的当vtemp0v \ temp 0vtemp0的时候我们显然可以构造出vtemp∣tempv temp | tempvtemp∣temp也是符合条件的。
代码
#include bits/stdc.husing namespace std;typedef long long ll;inline ll read() {ll f 1, x 0;char c getchar();while(c 0 || c 9) {if(c -) f -1;c getchar();} while(c 0 c 9) {x (x 1) (x 3) (c ^ 48);c getchar();}return f * x;
}int main() {// freopen(in.txt, r, stdin);// freopen(out.txt, w, stdout);ios::sync_with_stdio(false);ll u read(), v read();if(((u 1) (v 1)) (v u)) {if(u v) {if(!u) puts(0);else cout 1\n u \n;}else {ll temp v - u 1;if((temp u) 0)cout 2\n u temp temp \n;else cout 3\n u temp temp \n;}}else puts(-1);return 0;
}