博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
good bye 2015 B - New Year and Old Property
阅读量:4581 次
发布时间:2019-06-09

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

题意:统计在n,m之间的数的二进制表示形式只有一个零的数目。

位运算模拟+dfs

1 #include
2 #include
3 #include
4 #include
5 #include
6 #include
7 #include
8 #include
9 #include
10 #include
11 #include
12 #include
13 #include
14 using namespace std;15 #define INF 0x3f3f3f3f16 #define ll long long17 #define clc(a,b) memset(a,b,sizeof(a))18 const int maxn=1000000;19 20 ll n,m;21 ll ans;22 void dfs(ll a,ll b)23 {24 if(a>m)25 return ;26 if(a>=n&&a<=m&&b==1)27 ans++;28 if(b==0)29 dfs(a*2,1);30 dfs(a*2+1,b);31 }32 33 int main()34 {35 while(~scanf("%I64d%I64d",&n,&m))36 {37 ans=0;38 dfs(1,0);39 printf("%I64d\n",ans);40 }41 return 0;42 }
View Code

 

转载于:https://www.cnblogs.com/ITUPC/p/5154188.html

你可能感兴趣的文章
python pip源配置,pip配置文件存放位置
查看>>
[数据库]关于MAX()函数的一个坑
查看>>
实现前后滚动效果-axure设计实例
查看>>
windows下mysql忘记root密码--吐血测试,都是泪
查看>>
lnmp集成开发环境安装pdo_dblib扩展
查看>>
linux web.py spawn-fcgi web.py 配置
查看>>
lintcode : 空格替换
查看>>
lintcode 中等题:subsets II 带重复元素的子集
查看>>
【原创】Linux基础之测试域名IP端口连通性
查看>>
webstorm快捷键大全
查看>>
SQL Server 语法大全
查看>>
MySQL存储过程
查看>>
HttpContext是干什么的
查看>>
线程安全
查看>>
原形模式
查看>>
iOS开发笔记5:多线程之NSThread、NSOperation及GCD
查看>>
php中curl的详细解说【转】
查看>>
Codeforces Round #281 (Div. 2) C. Vasya and Basketball 二分
查看>>
hdu 6069 Counting Divisors 筛法
查看>>
codeforces gym 100971 K Palindromization 思路
查看>>