C. Hexadecimal's Numbers

题目连接:

http://www.codeforces.com/contest/9/problem/C

Description

One beautiful July morning a terrible thing happened in Mainframe: a mean virus Megabyte somehow got access to the memory of his not less mean sister Hexadecimal. He loaded there a huge amount of n different natural numbers from 1 to n to obtain total control over her energy.

But his plan failed. The reason for this was very simple: Hexadecimal didn't perceive any information, apart from numbers written in binary format. This means that if a number in a decimal representation contained characters apart from 0 and 1, it was not stored in the memory. Now Megabyte wants to know, how many numbers were loaded successfully.

Input

Input data contains the only number n (1 ≤ n ≤ 109).

Output

Output the only number — answer to the problem.

Sample Input

10

Sample Output

2

Hint

题意

问你小于等于n的数里面,有多少个只由0和1组成的

题解:

感觉上没多少个数嘛,那就直接dfs就好了啦

代码

#include<bits/stdc++.h>
using namespace std;
long long n;
map<int,int> vis;
long long ans = 0;
void dfs(long long x)
{if(x>n)return;if(vis[x])return;vis[x]=1;ans++;dfs(x*10);dfs(x*10+1);
}
int main()
{cin>>n;dfs(1);cout<<ans<<endl;
}

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

  1. Codeforces Beta Round #75 (Div. 1 Only) B. Queue 线段树。单点更新

    http://codeforces.com/problemset/problem/91/B 题意: 给你n个数,求得i 到n中小于a[i]的最右边的a[j],然后求a[i]到a[j]之间包含了多少个数 ...

  2. Codeforces Beta Round #22 (Div. 2 Only) E. Scheme(DFS+强连通)

    题目大意 给了 n(2<=n<=105) 个点,从每个点 u 出发连向了一个点 v(共 n 条边) 现在要求添加最少的边使得整个图是一个强连通图 做法分析 这道题千万不要一般化:先求强连通 ...

  3. Codeforces Beta Round #4 (Div. 2 Only)

    Codeforces Beta Round #4 (Div. 2 Only) A 水题 1 #include<bits/stdc++.h> 2 using namespace std; 3 ...

  4. Codeforces Beta Round #9 (Div. 2 Only)【未完结】

    2022.3.6 题目地址:https://codeforces.com/contest/9 目录 A. Die Roll B. Running Student[枚举] C. Hexadecimal' ...

  5. Codeforces Beta Round #92 (Div. 1 Only) A. Prime Permutation 暴力

    A. Prime Permutation 题目连接: http://www.codeforces.com/contest/123/problem/A Description You are given ...

  6. Codeforces Beta Round #9 (Div. 2 Only) D. How many trees? dp

    D. How many trees? 题目连接: http://www.codeforces.com/contest/9/problem/D Description In one very old t ...

  7. Codeforces Beta Round #14 (Div. 2) B. Young Photographer 水题

    B. Young Photographer 题目连接: http://codeforces.com/contest/14/problem/B Description Among other thing ...

  8. Codeforces Beta Round #96 (Div. 1) D. Constants in the language of Shakespeare 贪心

    D. Constants in the language of Shakespeare Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codef ...

  9. Codeforces Beta Round #16 (Div. 2 Only)【未完结】

    2022.3.9 题目地址:https://codeforces.com/contest/16 目录 A. Flag[模拟] B. Burglar and Matches[贪心] C. Monitor ...

最新文章

  1. 2020年Yann Lecun深度学习笔记(下)
  2. 黄聪:NaviCat通过Http方式连接服务器的MySQL数据库(转)
  3. 动态路由和动态路由中的RIP协议
  4. lua 从一串数字中取出偶数位的数字_为什么JavaScript中 0.1 0.2 不等于0.3?
  5. 上海区块链会议演讲ppt_进行第一次会议演讲的完整指南
  6. mysql连接规定时区以及编码_springboot项目中使用mysql连接遇到时区timezone问题,和编码encoding问题解决...
  7. ArcGIS for Android 中实现要素绘制时固定MapView
  8. drools 将添加switch支持
  9. 数值分析(7)-正交多项式
  10. 聊聊BA无标度网络以及其作用
  11. 基于JSP网上购书系统
  12. 随机过程(1.2)—— 数学期望与条件期望
  13. 【LeetCode】975. Odd Even Jump 解题报告(C++)
  14. 宝塔服务器性能跑分排行榜(CPU/内存/系统)
  15. h5后缀文件python处理
  16. canvas实现英雄联盟战力图
  17. 9月11日 XE8移动开发入门(五)XE8中使用DataSnap三层架构和Beacon组件简介
  18. 【无标题】7-11 sdut-C语言实验- 数列有序! 7-12 sdut-C语言实验- 中位数 7-13 sdut-C语言实验-各位数字之和排序 7-14 sdut-C语言实验- 冒泡排序中数据交换
  19. zzulioj 1787: 生化危机 (vector+dfs) 好题
  20. 【转】什么是加密经济学

热门文章

  1. PHP算法之四大基础算法
  2. PHP 7.3 我们将迎来灵活的 heredoc 和 nowdoc 句法结构
  3. [可行]setoolkit生成木马软件远程控制实例
  4. linux基础lvm
  5. Linux-HA 高可用开源方案 Keepalived VS Heartbeat 对比
  6. Linux中java项目环境部署,简单记录一下
  7. 源码编译安装nginx1.4.7
  8. vc++6.0获取磁盘基本信息_分享一个实用脚本--一键获取linux内存、cpu、磁盘IO等信息...
  9. Linux Anaconda断网创建虚拟环境
  10. MYSQL密码解密函数的使用