defcount_no_101(l, r):count = 0for num in range(l, r + 1):binary = bin(num)[2:] # 将数字转换为二进制字符串if '101' not in binary:count += 1return count# 输入l, r = map(int, input.split)# 计算并输出结果result = count_no_101(l, r)print(result)摘要:defcount_no_101(l, r):count = 0for num in range(l, r + 1):binary = bin(num)[2:] # 将数字转换为二进制字符串if '101' not in binary:count += 1ret
来源:若若课堂
免责声明:本站系转载,并不代表本网赞同其观点和对其真实性负责。如涉及作品内容、版权和其它问题,请在30日内与本站联系,我们将在第一时间删除内容!