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. 【BZOJ1283/3550】序列/[ONTAK2010]Vacation 最大费用流

    [BZOJ1283]序列 Description 给出一个长度为 的正整数序列Ci,求一个子序列,使得原序列中任意长度为 的子串中被选出的元素不超过K(K,M<=100) 个,并且选出的元素之和 ...

  2. APP测试瞎话

    APP测试        一.功能性        1.APP的安装.卸载        2.APP中业务功能            二.性能测试        1.高.中.低端机上运行效果      ...

  3. idle命令行按ALT+P重复调出上个语句

    idle命令行按ALT+P重复调出上个语句

  4. java反射——构造方法

    大家都知道反射技术在Java里面时非常重要的一个技术点,因为Java好多框架的编写都是基于反射的,别的不多说,spring框架里面的IOC就是基于反射实现.那么什么是反射呢?JAVA反射机制是在运行状 ...

  5. 实践中需要了解的cpu特性

    目录 分段机制 特权级检查 GDT和LDT 堆栈切换 分页机制 中断 分段机制 实模式中cs是一个实实在在的段首地址,ip为cs所指向段的偏移,所以cs<<4+ip是当前cpu执行的指令. ...

  6. Casperjs中fill提交表单遇到的问题

    1.if you access internet with proxy please add             --ignore-ssl-errors=true --ssl-protocol=a ...

  7. 转!!Java的三种代理模式

    转自 http://www.cnblogs.com/cenyu/p/6289209.html 1.代理模式 代理(Proxy)是一种设计模式,提供了对目标对象另外的访问方式;即通过代理对象访问目标对象 ...

  8. 【我的Android进阶之旅】推荐一款能提升数十倍效率的Android应用开发助手

    一功能介绍 a调试相关 1布局边界 2布局更新 3强制GPU渲染 4GPU渲染 5指针位置 6严格模式 7不保留应用 8不锁定屏幕 9开发者选项 10系统设置 11语言设置 12USB调试 b UI相 ...

  9. Linux学习笔记(7)CRT实现windows与linux的文件上传下载

    Linux学习笔记(7)CRT实现windows与linux的文件上传下载 按下Alt + p 进入SFTP模式,或者右击选项卡进入 命令介绍 help 显示该FTP提供所有的命令 lcd 改变本地上 ...

  10. error:No resource found that matches the given name 'Theme.AppCompat.Light'

    一.stsckoverflow http://stackoverflow.com/questions/17870881/cant-find-theme-appcompat-light-for-new- ...