每行有两个不大于65535的非负整数
对于每一行的两个整数,输出一行,内容为YES或NO
2 4 9 18 45057 49158 7 12
YES YES YES NO
while True: try: n1,n2=map(int,input().strip().split(' ')) def data(i,str1): i_list=list(i) lenth=len(i_list) str1_list=list(str1) result=False for j in range(lenth): index=i_list.pop(0) i_list.append(index) if i_list==str1_list: result=True break return result n1_bin=bin(n1).lstrip('0b') n2_bin=bin(n2).lstrip('0b') lenth1=len(n1_bin) lenth2=len(n2_bin) n1_bin='0'*(16-lenth1)+n1_bin n2_bin='0'*(16-lenth2)+n2_bin if data(n1_bin,n2_bin) or data(n2_bin,n1_bin): print('YES') else: print('NO') except: break
try: while True: a,b = list(map(int,input().split())) a = "{:0>16}".format(bin(a).replace('0b','')) #转换成16位二进制 b = "{:0>16}".format(bin(b).replace('0b','')) for i in range(16): #循环左移 a = a[1:]+a[0] if a == b: print("YES") break else:print("NO") except Exception: pass
from collections import deque
a = int(input())
for i in range(a):
a, b = map(lambda c: bin(c).replace("0b", "").rjust(16, "0"), map(int, input().split()))
hasSolution = False
for i in range(16):
rotateDeque = deque(a)
rotateDeque.rotate(-i)
if rotateDeque == deque(b):
hasSolution = True
break
print("YES" if hasSolution else "NO")