首页 > TAG信息列表 > Xorcist
D. Ehab the Xorcist
D. Ehab the Xorcist time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Given 2 integers uu and vv, find the shortest array such that bitwise-xor of its elements is uu, and the sum ofD. Ehab the Xorcist
题意: 略; 感觉被演了一波,这是CFdiv2吗? 算是这个构造题吧。 1 首先我们可以将u进行二进制拆分来考虑。加入u>v那么小与v的那些数在怎么拼接也无法使异或值为u。 比如二进制U=1 0 1 1 0。怎么才能异或成这个数呢?无非就是让1所在的位置的1的个数为奇数就行了,也就是构成异或成U的最小Codeforces Round #628 (Div. 2) D. Ehab the Xorcist 题解(思维+位运算)
原题链接:https://codeforces.com/contest/1325/problem/D Given 2 integers u and v, find the shortest array such that bitwise-xor of its elements is u, and the sum of its elements is v. Input The only line contains 2 integers u and v (0≤u,v≤1018).(0≤u