第二题,美丽数
def is_beauti(num, t):
if num < 10:
if num == t: return True
else: return False
hash_nums = [hash[c][::-1] for c in str(num)]
hash_t = "{0:b}".format(t)
for index, cur in enumerate(hash_t[::-1]):
nums_cur = [each[index] for each in hash_nums]
if cur == '1':
if len(set(nums_cur)) != 2:
return False
else:
if len(set(nums_cur)) != 1:
return False
return True
def beauti_count(l, r, t):
count = 0
for num in range(l, r+1):
if is_beauti(num, t, ):
count += 1
return count
T = int(input())
left = list(map(int, input().split()))
right = list(map(int, input().split()))
nums = list(map(int, input().split()))
result = []
hash = {'0':'0000', '1':'0001', '2':'0010', '3':'0011', '4':'0100', '5':'0101', '6':'0110', '7':'0111', '8':'1000', '9':'1001'}
for l, r, t in zip(left, right, nums):
count = beauti_count(l, r, t)
print(count)