lanmengfei @ 2023-09-02 12:34:18
AC code:
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d;
cin>>a>>b;
do{
c=a^b;
d=(a&b)<<1;
a=c;
b=d;
}while(b!=0);
cout<<a;
return 0;
}
by coool @ 2023-09-02 13:00:37
@lanmengfei 位运算,用纸笔模拟下就知道了
by lllcccaaa @ 2023-09-02 18:22:32
看看我的:
#include<bits/stdc++.h>
using namespace std;
int sub(int a,int b){
if(!a)return b;
return sub((a&b)<<1,a^b);
}
int main(){
int a,b;
cin>>a>>b;
cout<<sub(a,b)<<endl;
return 0;
}
by Hugest_Brain @ 2023-09-04 09:11:33
@lanmengfei 看看我的:(发不出来
#include<bits/stdc++.h>
#define ? using
#define ? namespace
by Hugest_Brain @ 2023-09-04 09:12:26
@lanmengfei 干脆看我主页上的代码,(加入代码公开
by lanmengfei @ 2023-09-08 21:16:32
@Huge__Brain 6
by __delta_epsilon__ @ 2023-09-23 21:47:34
感觉不如:
# /**/ include <bits/stdc++.h>
#define \
genshin \
namespace
using
genshin // 启动!
std ;
# define int long \
/* long */ /*
\* |
*\ * |*
\ *|
*\ * |*
\*/\
long //;
; ; ;;;;; ; ; ;;;;;
; ; ; ; ; ; ;
;;;;; ;;;;; ; ; ; ;
; ; ; ; ; ; ;
; ; ;;;;; ;;;;; ;;;;; ;;;;;
#define l \
(
# define L {
main l
int a,
int
b ) L
cin >>
a
>> b
;
; cout /*
*/ //\
\ 原 \
\ 神 \
\ , \
\ 启 \
\ 动 \
\ ! \
*/
<< l 1,
'G',
'e',
'n',
's',
'h',
'i',
'n',
l
a/*
+ *
*/ + /*
* +
*b)*/ b)
)<<
endl;
if(0)
;return
0^(0x0)^0 ;
; exit l 1l*
0-(0)-0 );
// \\
}
}
by laozhang_123 @ 2023-09-27 20:17:37
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstring>
using namespace std;
struct node
{
int data,rev,sum;
node *son[2],*pre;
bool judge();
bool isroot();
void pushdown();
void update();
void setson(node *child,int lr);
}lct[233];
int top,a,b;
node *getnew(int x)
{
node *now=lct+ ++top;
now->data=x;
now->pre=now->son[1]=now->son[0]=lct;
now->sum=0;
now->rev=0;
return now;
}
bool node::judge(){return pre->son[1]==this;}
bool node::isroot()
{
if(pre==lct)return true;
return !(pre->son[1]==this||pre->son[0]==this);
}
void node::pushdown()
{
if(this==lct||!rev)return;
swap(son[0],son[1]);
son[0]->rev^=1;
son[1]->rev^=1;
rev=0;
}
void node::update(){sum=son[1]->sum+son[0]->sum+data;}
void node::setson(node *child,int lr)
{
this->pushdown();
child->pre=this;
son[lr]=child;
this->update();
}
void rotate(node *now)
{
node *father=now->pre,*grandfa=father->pre;
if(!father->isroot()) grandfa->pushdown();
father->pushdown();now->pushdown();
int lr=now->judge();
father->setson(now->son[lr^1],lr);
if(father->isroot()) now->pre=grandfa;
else grandfa->setson(now,father->judge());
now->setson(father,lr^1);
father->update();now->update();
if(grandfa!=lct) grandfa->update();
}
void splay(node *now)
{
if(now->isroot())return;
for(;!now->isroot();rotate(now))
if(!now->pre->isroot())
now->judge()==now->pre->judge()?rotate(now->pre):rotate(now);
}
node *access(node *now)
{
node *last=lct;
for(;now!=lct;last=now,now=now->pre)
{
splay(now);
now->setson(last,1);
}
return last;
}
void changeroot(node *now)
{
access(now)->rev^=1;
splay(now);
}
void connect(node *x,node *y)
{
changeroot(x);
x->pre=y;
access(x);
}
void cut(node *x,node *y)
{
changeroot(x);
access(y);
splay(x);
x->pushdown();
x->son[1]=y->pre=lct;
x->update();
}
int query(node *x,node *y)
{
changeroot(x);
node *now=access(y);
return now->sum;
}
int main(){
int a,b;
cin>>a>>b;
cout<<a+b<<endl;
return 0;
}
by lanmengfei @ 2023-09-28 11:26:19
666
by _3145114514_ @ 2023-10-07 21:37:07
看看我的
#include<iostream>
using namespace std;
typedef int _;
#define __________ main
_ ______;
_ __(_ ___,_ _______)
{
if(!_______)
{
return ___;
}
return __(___^_______,(___ & _______)<<(((___-_______)&(___-___))^______));
}
_ __________()
{
_ ____, ___;
______++;
scanf("%d%d", &____, &___);
printf("%d", __(____, ___));
return 0;
}
by lihaoda @ 2023-11-03 19:46:56
小白路过:大佬们不会用万能头文件吗?