CodeForces 611B - New Year and Old Property(搜索)

博客讲述了CodeForces中编号为611B的一道编程题目,该题目要求求解在给定的两个年份之间,有多少年的二进制表示只包含一个零。输入包含两个整数,输出符合条件的年份数量。解决方案是通过深度优先搜索遍历所有只含一个零的二进制数。
摘要由CSDN通过智能技术生成

B. New Year and Old Property
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
The year 2015 is almost over.

Limak is a little polar bear. He has recently learnt about the binary system. He noticed that the passing year has exactly one zero in its representation in the binary system — 201510 = 111110111112. Note that he doesn’t care about the number of zeros in the decimal representation.

Limak chose some interval of years. He is going to count all years from this interval that have exactly one zero in the binary representation. Can you do it faster?

Assume that all positive integers are always written without leading zeros.

Input
The only line of the input contains two integers a and b (1 ≤ a ≤ b ≤ 1018) — the first year and the last year in Limak’s interval respectively.

Output
Print one integer – the number of years Limak will count

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值