博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
POJ 3252 Round Numbers
阅读量:6786 次
发布时间:2019-06-26

本文共 2360 字,大约阅读时间需要 7 分钟。

Time Limit: 2000MS   Memory Limit: 65536KB   64bit IO Format: %I64d & %I64u

[]   []   []  

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

Source

[]   []   []  

#include 
#include
#include
#include
using namespace std;typedef long long int LL;int bit[70],bn;LL C[100][100],g[100];void init_C(){ for(int i=0;i<100;i++) C[i][0]=C[i][i]=1LL; for(int i=2;i<100;i++) { for(int j=1;j
=t-i+1) { ret+=C[t][i]; } } return ret;}void init(){ for(int i=1;i<=100;i++) g[i]=GAO_x(i);}int n1[1000];LL calu(LL x){ LL ret=1; for(int i=1;i
=0;i--) { if(bit[i]==0) { zero++; continue; } else { int t0=zero+1,t1=one; for(int j=0;j<=i;j++) { if(j+t0>=one+i-j) { ret+=C[i][j]; } } one++; } } if(zero>=one) ret++; return ret;}int main(){ init_C();init(); LL x,y; while(cin>>x>>y) { if(y

转载地址:http://ssbgo.baihongyu.com/

你可能感兴趣的文章
Google Earth网页版初探
查看>>
Mysql数据库连接池知识分享
查看>>
SpringMVC 拦截请求,判断会话是否超时
查看>>
网站前端_KindEditor.基础入门.0001.KindEditor_3.4.2快速入门?
查看>>
android拍照并通过Http发送到Java后台
查看>>
ubuntu安装nginx-1.8.0.tar.gz
查看>>
魔兽争霸3地图(WarIII Maps):妖皇传说
查看>>
grub2正确配置——硬盘安装ubuntu 9.10之后不能启动xp解决方法
查看>>
PHP isset()与empty()的使用区别详解
查看>>
mysql 修改数据库的时区
查看>>
MyBatis 通过包含的jdbcType类型
查看>>
Web应用中的中文问题
查看>>
with as 中绑定变量的使用
查看>>
时间:2014年4月8日17:01:10 GD完成验证码
查看>>
mysql主从同步
查看>>
微信机器人高级版常见问题汇总
查看>>
容器技术|Docker三剑客之docker-machine
查看>>
Masonry 第三方框架页面自动布局
查看>>
博客转移声明
查看>>
利用论坛营销推广的完美“6步曲”
查看>>