D-位运算&结论+公式推导
结论:
- x + y = 2 ( x x+y=2(~x~ x+y=2( x & y ) + ( x ~y~)+~(~x~ y )+ ( x ^ y ) ~y~)~ y )
- ( x (~x~ ( x & y ) ~y~)~ y ) & ( x ~(~x~ ( x ^ y ) = 0 ~y~)=0 y )=0
本题定义的 A N D AND AND即 &
x + y = s , x x+y=s,~x~ x+y=s, x & y = a ~y=a y=a
s
=
2
a
+
~s=2a+
s=2a+
(
x
(~x
( x^
y
)
(
1
)
~y~)(1)
y )(1)
a
a~
a &
(
x
~(~x~
( x ^
y
)
=
0
(
2
)
~y~)=0 (2)
y )=0(2)
由(1)(2)得到: s ≥ 2 a , a s≥2a,~a~ s≥2a, a & ( s − 2 a ) = 0 (s-2a)=0 (s−2a)=0
#include<iostream>
using namespace std;
long long a,s,t;
int main()
{
cin>>t;
while(t--)
{
cin>>a>>s;
if((s>=2*a)&&(((s-2*a)&a)==0))
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}
return 0;
}