# Round Numbers

http://poj.org/problem?id=3252

 Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 17293 Accepted: 7188

Description

The cows, as you know, have no fingers or thumbs and thus are unable to play Scissors, Paper, Stone' (also known as 'Rock, Paper, Scissors', 'Ro, Sham, Bo', and a host of other names) in order to make arbitrary decisions such as who gets to be milked first. They can't even flip a coin because it's so hard to toss using hooves.

They have thus resorted to "round number" matching. The first cow picks an integer less than two billion. The second cow does the same. If the numbers are both "round numbers", the first cow wins,
otherwise the second cow wins.

A positive integer N is said to be a "round number" if the binary representation of N has as many or more zeroes than it has ones. For example, the integer 9, when written in binary form, is 1001. 1001 has two zeroes and two ones; thus, 9 is a round number. The integer 26 is 11010 in binary; since it has two zeroes and three ones, it is not a round number.

Obviously, it takes cows a while to convert numbers to binary, so the winner takes a while to determine. Bessie wants to cheat and thinks she can do that if she knows how many "round numbers" are in a given range.

Help her by writing a program that tells how many round numbers appear in the inclusive range given by the input (1 ≤ Start < Finish ≤ 2,000,000,000).

Input

Line 1: Two space-separated integers, respectively Start and Finish.

Output

Line 1: A single integer that is the count of round numbers in the inclusive range Start..Finish

Sample Input

`2 12`

Sample Output

```6

```
``` #include<iostream>
#include<cstring>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eb emplace_back
#define maxn 13000005
#define eps 1e-8
#define pi acos(-1.0)
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,int>pli;
typedef pair<char,int> pci;
typedef pair<pair<int,string>,pii> ppp;
typedef unsigned long long ull;
const long long MOD=1e9+;
/*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */

int dp[][];
int a[];
int num;

int dfs(int pos,int sta,bool lead,bool limit){
if(pos==-) return sta>=;
int up=limit?a[pos]:;
int ans=;
for(int i=;i<=up;i++){
}
return ans;
}
int solve(int x){
int pos=;
while(x){
a[pos++]=x%;
x>>=;
}
return dfs(pos-,,true,true);
}

int main(){
#ifndef ONLINE_JUDGE
//   freopen("1.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
int n,m;
memset(dp,-,sizeof(dp));
while(cin>>n>>m){
cout<<solve(m)-solve(n-)<<endl;
}
}```

## Round Numbers(数位DP)的更多相关文章

1. poj 3252 Round Numbers(数位dp 处理前导零)

Description The cows, as you know, have no fingers or thumbs and thus are unable to play Scissors, P ...

2. 4-圆数Round Numbers(数位dp)

Round Numbers Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 14947   Accepted: 6023 De ...

3. POJ3252 Round Numbers —— 数位DP

题目链接:http://poj.org/problem?id=3252 Round Numbers Time Limit: 2000MS   Memory Limit: 65536K Total Su ...

4. POJ 3252 Round Numbers(数位dp&amp;amp;记忆化搜索)

题目链接:[kuangbin带你飞]专题十五 数位DP E - Round Numbers 题意 给定区间.求转化为二进制后当中0比1多或相等的数字的个数. 思路 将数字转化为二进制进行数位dp,由于 ...

5. POJ - 3252 - Round Numbers(数位DP）

链接: https://vjudge.net/problem/POJ-3252 题意: The cows, as you know, have no fingers or thumbs and thu ...

6. poj 3252 Round Numbers 数位dp

题目链接 找一个范围内二进制中0的个数大于等于1的个数的数的数量.基础的数位dp #include<bits/stdc++.h> using namespace std; #define ...

7. 【poj3252】 Round Numbers (数位DP+记忆化DFS)

题目大意:给你一个区间\$[l,r]\$,求在该区间内有多少整数在二进制下\$0\$的数量\$≥1\$的数量.数据范围\$1≤l,r≤2*10^{9}\$. 第一次用记忆化dfs写数位dp,感觉神清气爽~(原谅我这个 ...

8. \$POJ\$3252 \$Round\ Numbers\$ 数位\$dp\$

正解:数位\$dp\$ 解题报告: 传送门\$w\$ 沉迷写博客,,,不想做题,,,\$QAQ\$口胡一时爽一直口胡一直爽\$QAQ\$ 先港下题目大意嗷\$QwQ\$大概就说,给定区间\$[l,r]\$,求区间内满足二进制 ...

9. POJ Round Numbers(数位DP)

题目大意: Round Number:  将一个整数转化为二进制数字后,(不含前导0) 要是0的个数 大于等于1的个数 则是 Round Number 问从L-R之中有多少个Round Number ...

## 随机推荐

1. springmvc 数据精准绑定

因为使用dwz 的lookup功能,回调的值通过name以 xxx.xxValue 来自动得到,而我还有些表单数据的name是没有前缀的, 到springmvc后台绑定的的话默认的绑定是有问题的.这是 ...

2. PIC12F629帮我用C语言写个程序，控制三个LED亮灭

http://power.baidu.com/question/240873584599025684.html?entry=browse_difficult PIC12F629帮我用C语言写个程序,控 ...

3. Absolute sort

Absolute sort Let's try some sorting. Here is an array with the specific rules. The array (a tuple) ...

4. GridView规则显示图片

首先是自定义的GridVIew,ListView嵌套GridVIew时必须自定义GridVIew,不嵌套时可以不用.这里的GridView会根据图片多少自动调节大小 //自定义的GridView ,以 ...

5. p1221网络布线（最小生成树 Prim（普里母）算法） p1222 Watering Hole

描述 Description 农民约翰被选为他们镇的镇长!他其中一个竞选承诺就是在镇上建立起互联网,并连接到所有的农场.当然,他需要你的帮助.约翰已经给他的农场安排了一条高速的网络线路,他想把这条线路 ...

6. lua 运算符

lua 运算符 算术运算符 操作符 描述 + 加 - 减 * 乘 / 除 % 求模 ^ 求幂 示例程序 local a, b = 1, 2 print(a + b) print(a - b) prin ...

7. Linux服务器的远程IP限制

系统环境: Linux-centOS+ubuntu 操作: 编辑允许通过IP 路径:vim /etc/hosts.allow sshd:192.168.1.1 编辑禁止通过IP 路径:vim /etc ...

8. Python-老男孩-02_装饰器_面向对象_封装_继承_异常_接口_数据库

装饰器其实也是一个函数,它的参数是一个函数 ; 其它函数与装饰器之间建立联系是通过 @装饰器函数名, 感觉有点像Spring的面向切面编程 装饰器函数,如何处理原函数的参数.?  装饰器 原函数返回值 ...

9. 利用phpspider爬取网站数据

本文实例原址:PHPspider爬虫10分钟快速教程 在我们的工作中可能会涉及到要到其它网站去进行数据爬取的情况,我们这里使用phpspider这个插件来进行功能实现. 1.首先,我们需要php环境, ...

10. 1.2 SQL运算与控制程序执行流程

列出需要注意和学习的运算 1.取余 2.begin....end:中间包含两条或两条以上的SQL语句 3.case:进行多重选择,免于写if   then的嵌套循环.  通配符:(实现模糊查询) %: ...