xor表示异或,(a^b=c )<==>( a^c=b)

Xor Transformation

https://ac.nowcoder.com/acm/contest/13605/G

      a^b=c
<==>  a^c=b
<==>  b^c=a

//

#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll x,y,a;
queue<ll>q;
void pri(){
    cout << q.size() << "\n";
    while(!q.empty()){
        cout << q.front() << " ";
        q.pop();
    }
}
void fun(ll a,ll b,ll c){
    c=a^b;
    if(c==y&&c<a){
        pri();return ;
    }
    if(c>=a){
        q.push((a^c));
        fun(c,b,c);
    }
    else{
        q.push(c);
        pri();
    }
}
int main(){
    cin >> x >> y;
    fun(x,y,x);
    return 0;
}
全部评论

相关推荐

12-13 14:51
已编辑
井冈山大学 算法工程师
龙虾x:算法比你强的没有你美,比你美的…..算了已经没有比你美的了
工作两年想退休了
点赞 评论 收藏
分享
影04714:把图书管理系统那个项目经验内容适当的减少掉,然后改成据为己有不要说团队项目,因为图书管理系统这类常见的谁来了都能独立写出来,提问能圆过来即可
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务