2017-08-01 21:35:53

writer:pprp

集训第一天:作为第一道题来讲,说了两种算法,

  第一种是跟二进制数联系起来进行分析;

  第二种是用深度搜索来做,虽然接触过深度搜索但是这种题型还是我第一次见;

题目:

  统计1~n之间有多少数字只由0,1构成
  1 ≤ n ≤ 1e9

用深度搜索解决这种问题;


代码如下:

#include <iostream>
#include <map> using namespace std; map<int,int>vis; long long ans = ; int n; //深度搜索,模仿
void dfs(int x)
{
if(x > n)
return;
if(vis[x])
return;
vis[x] = ;
ans++;
dfs(x*);
dfs(x*+);
} int main()
{
cin >> n; dfs(); cout << ans << endl; return ;
}

遇到的问题:不知道为什么用数组来取代map就不能通过,最后还是用了map

Codeforces 9C Hexadecimal's Numbers - 有技巧的枚举的更多相关文章

  1. Codeforce 9C - Hexadecimal's Numbers

    One beautiful July morning a terrible thing happened in Mainframe: a mean virus Megabyte somehow got ...

  2. Codeforces Beta Round #9 (Div. 2 Only) C. Hexadecimal's Numbers dfs

    C. Hexadecimal's Numbers 题目连接: http://www.codeforces.com/contest/9/problem/C Description One beautif ...

  3. codeforces 9 div2 C.Hexadecimal's Numbers 暴力打表

    C. Hexadecimal's Numbers time limit per test 1 second memory limit per test 64 megabytes input stand ...

  4. [codeforces 55]D. Beautiful numbers

    [codeforces 55]D. Beautiful numbers 试题描述 Volodya is an odd boy and his taste is strange as well. It ...

  5. C. Hexadecimal's Numbers

    C. Hexadecimal's Numbers time limit per test 1 second memory limit per test 64 megabytes input stand ...

  6. CodeForces - 1245A Good ol' Numbers Coloring (思维)

    Codeforces Round #597 (Div. 2 Consider the set of all nonnegative integers: 0,1,2,-. Given two integ ...

  7. CodeForces 682A Alyona and Numbers (水题)

    Alyona and Numbers 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/A Description After fi ...

  8. Codeforces 449D Jzzhu and Numbers

    http://codeforces.com/problemset/problem/449/D 题意:给n个数,求and起来最后为0的集合方案数有多少 思路:考虑容斥,ans=(-1)^k*num(k) ...

  9. 9 C. Hexadecimal's Numbers

    题目链接 http://codeforces.com/contest/9/problem/C 题目大意 输入n,计算出n之内只有0和1组成的数字的数量 分析 k从1开始,只要小于n,就给sum++,并 ...

随机推荐

  1. JZOJ.5235【NOIP2017模拟8.7】好的排列

    Description 对于一个1->n的排列 ,定义A中的一个位置i是好的,当且仅当Ai-1>Ai 或者Ai+1>Ai.对于一个排列A,假如有不少于k个位置是好的,那么称A是一个好 ...

  2. shiro权限笔记

    shiro框架运行流程 认证:系统提供的用于识别用户身份的功能,通常就是登录功能.----让系统知道你是谁??授权:系统提供的为用户分配访问系统某些功能的能力.----让系统知道你能做什么?? 官网: ...

  3. x-webkit-speech语音搜索

    如果你没看到语音图标说明你的浏览器不支持x-webkit-speech 换个chrome你会发现输入框的右侧出现语音小图标.

  4. TCL V7300A-3D升级教程

    鄙人的电视型号: 机器软件版本:V8-0MT-3201-LF1V028_000 3201是机芯 v028是版本号 设备型号:cn_mt32-v7300a-3d TCL电视升级有三个:本地.网络.自动 ...

  5. Grammar Rules

    Grammar Rules Here are 20 simple rules and tips to help you avoid mistakes in English grammar. For m ...

  6. windows 键盘全局钩子

    // HookapiTest.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <Windows.h> #inc ...

  7. QT解析嵌套JSON表达式

    QT5开发环境集成了解析JSON表达式的库.使用很方便. 友情提示一下,好像在QT4环境里.须要到官网下载相关的库文件才干使用解析功能.话不多说,上代码 1.在pro文件里增加 QT += scrip ...

  8. python基础(数字、字符串、布尔值、字典数据类型简介)

    一 执行第一个python程序 1.下载安装python2.7和python3.6的版本及pycharm,我们可以再解释器中输入这样一行代码: 则相应的就打出了一句话.这里的print是打印的意思.你 ...

  9. python 2 和python 3的 区别

    用户交互 input  ps:python2:raw_input python3:input 在 python2里 print不需要加括号也可以打印 子python3里 print 必须加括号才能打印

  10. Windows Live Writer 网易博客配置

    一.去官网下载 Windows Live Write 组件 二.配置,选中其它服务,然后会到如下界面 主要是这里经常不知道选择什么,容易忘记. 下拉框选中metaweblog API 类型,把这个地址 ...