您的位置:首页 > 运维架构

Codeforences Goodbye 2015 B New Year and Old Property

2016-01-12 22:14 369 查看
题目传送门

题意:算出 a,b 中 二进制下,含有 且 只含有1个0的数 的数目
解题方法:暴力(dfs)

#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,m;
ll ans;
void dfs(ll x,ll cnt)
{
if(x>m)return ;
if(x>=n&&x<=m&&cnt==1)
ans++;
if(cnt==0)
dfs(2*x,1);
dfs(2*x+1,cnt);
}

int main()
{
cin>>n>>m;
ans=0;
dfs(1,0);
cout<<ans<<endl;
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: