zoukankan      html  css  js  c++  java
  • good bye 2015 B

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

    位运算模拟+dfs

     1 #include<iostream>
     2 #include<string>
     3 #include<algorithm>
     4 #include<cstdlib>
     5 #include<cstdio>
     6 #include<set>
     7 #include<map>
     8 #include<vector>
     9 #include<cstring>
    10 #include<stack>
    11 #include<cmath>
    12 #include<queue>
    13 #include <bits/stdc++.h>
    14 using namespace std;
    15 #define INF 0x3f3f3f3f
    16 #define ll long long
    17 #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
    ",ans);
    40     }
    41     return 0;
    42 }
    View Code
  • 相关阅读:
    字符串形式导入模块
    pycharm 远程环境开发调试
    ubuntu 18.04 及初始化python3环境
    nbu备份虚拟机
    转载
    linux/centos/rhel同时安装oracle10g和11g
    多进程
    drf笔记
    单例模式
    常用模块
  • 原文地址:https://www.cnblogs.com/ITUPC/p/5154188.html
Copyright © 2011-2022 走看看