codeforces 611B New Year and Old Property
来源:互联网 发布:部落冲突女王数据 编辑:程序博客网 时间:2024/05/16 17:16
题目大意:给你l和r,找出l和r中符合二进制形式只有一个0的数的个数
我们可以从1开始,向左移动一位就是在后面加一个0(x<<1),然后有了0以后,不断的移位+1就行
#include<iostream>using namespace std;typedef long long ll;ll l,r,ans=0;void dfs(ll n,ll flag){if(n>r) return;if(n>=l&&n<=r&&flag) ans++;if(flag==0) dfs(n<<1,1);dfs((n<<1)+1,flag);}int main(){ios::sync_with_stdio(false);cin>>l>>r;dfs(1,0);cout<<ans<<endl;}
阅读全文
0 0
- CodeForces 611 B. New Year and Old Property(水~)
- codeforces-611B-New Year and Old Property
- CodeForces 611B New Year and Old Property(DFS)
- CodeForces 611B - New Year and Old Property(搜索)
- 【Goodbye2015】Codeforces 611B New Year and Old Property【思维】
- codeforces 611B New Year and Old Property
- New Year and Old Property CodeForces
- New Year and Old Property CodeForces
- B. New Year and Old Property
- CodeForces 611B New Year and Old Property【DFS&&模拟位运算】
- 611B. New Year and Old Property【模拟位运算】
- CodeForces 611BNew Year and Old Property
- Codeforces Good Bye 2015 B. New Year and Old Property (DFS)
- codeforces - Goodbye2015B - New Year and Old Property(模拟)
- Codeforences Goodbye 2015 B New Year and Old Property
- cf#gb2015-B - New Year and Old Property-暴力
- codeforces611B. New Year and Old Property
- CodeForces 611BNew Year and Old Property(模拟)
- 2006
- Javascript 严格模式详解
- DSI (Display Serial Interface)
- iOS App加急审核步骤及经验
- 背包板子总结
- codeforces 611B New Year and Old Property
- git commit --amend两种用法
- MindManager盘点——舌尖上的中国
- 解决编译ROS节点时出现的问题 Error: package 'chapter2_tutorials' not found
- jstack调试结果CPU使用过高的问题
- Android UI基础java代码基础点
- 轻量级锁和偏向锁
- 每天研究一个产品,阿德老师“手摸手”带你写产品分析报告 |
- c