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. excel导出工具类

    package com.jianwu.util.excel; import com.google.common.collect.Lists;import com.jianwu.exception.Mo ...

  2. linux部署项目(Java项目+Tomcat+mysql)

    http://blog.csdn.net/liujiahan629629/article/details/27121739

  3. CodeForeces 665C Simple Strings

    C. Simple Strings time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  4. pro_select_roleinfo_p3

    DELIMITER | drop procedure if exists pro_select_roleinfo_p3; CREATE PROCEDURE pro_select_roleinfo_p3 ...

  5. explorer.exe中发生未处理的win32异常

    explorer.exe中发生未处理的win32异常的错误提示,是windows系统比较常见的错误事件,多数在开机遇到,也有在电脑使用过程中遇到. 了解explorer.exe进程 从百度百科了解到, ...

  6. 一篇搞定vue-router

    由于Vue常见于前后端分离开发场景下,所以页面跳转工作全部交给了前端,所以基于集中管理的原则,就有了vue-router插件,它给定了url和组件之间的跳转规则 Demo准备 vue init web ...

  7. Java实现对List去重

    方式一,使用for循环遍历去除List中的重复元素代码如下 public static void main(String[] args) { Test07 test07 = new Test07(); ...

  8. 我的Android进阶之旅------>Android Studio 快捷键整理分享

    正式转战Android Studio了,首先把Android Studio的快捷键摘录下来,以备后用. (官网的快捷键列表如下  https://developer.android.com/studi ...

  9. swift 值得学习的项目

    http://www.php100.com/html/it/biancheng/2015/0112/8329.html

  10. python的初识

    解释型语言 和编译型语言 计算机本身不能识别高级语言,当我们运行一个程序的时候,需要一个“翻译” 来把 高级语言转换成计算机能读懂的语言. “翻译”过程分两种: 编译 编译型语言在执行程序前,首先会通 ...