当前位置:网站首页>[51nod] 3047 displacement operation

[51nod] 3047 displacement operation

2022-06-24 02:49:00 SSL_ GYX

Displacement calculation

Link


 Insert picture description here

Their thinking

Strange judgment .
hold b b b The back of 0 0 0 Empty , if b b b yes a a a The string of , Then we can achieve by displacement .

code

#include<iostream>
#include<cstdio>
using namespace std;

int n;

int main()
{
    
	cin>>n;
	while(n--)
	{
    
		int a,b,flg=0;
		scanf("%d%d",&a,&b);
		if(!b)
		{
    
			printf("Yes\n");
			continue;
		}
		while(!(b&1)&&b) b>>=1;
		while(a>=b)
		{
    
			int t=a^b;
			if(((a&b)==b)&&((t&-t)>b||!t))
			{
    
				flg=1;
				break;
			}
			a>>=1;
		}
		printf("%s\n",(flg?"Yes":"No"));
	}
}
原网站

版权声明
本文为[SSL_ GYX]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202211645222007.html