Codeforce 9C - Hexadecimal's Numbers
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.
Example
Input
10
Output
2
Note
For n = 10 the answer includes numbers 1 and 10.
给你一个数,求1到这个数中有多少个只有1,0组成的数
解题思路:可以深搜,也可以直接构造
#include<stdio.h> long long sum, sum1; void dfs(long long a) {
if(sum<a)
return ;
sum1++;
dfs(a*);
dfs(a*+);
} int main() {
while(scanf("%lld", &sum)!=EOF) {
sum1 = ; dfs(); printf("%lld\n", sum1);
}
return ;
}
Codeforce 9C - Hexadecimal's Numbers的更多相关文章
- Codeforces 9C Hexadecimal's Numbers - 有技巧的枚举
2017-08-01 21:35:53 writer:pprp 集训第一天:作为第一道题来讲,说了两种算法, 第一种是跟二进制数联系起来进行分析: 第二种是用深度搜索来做,虽然接触过深度搜索但是这种题 ...
- 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 ...
- 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 ...
- C. Hexadecimal's Numbers
C. Hexadecimal's Numbers time limit per test 1 second memory limit per test 64 megabytes input stand ...
- 9 C. Hexadecimal's Numbers
题目链接 http://codeforces.com/contest/9/problem/C 题目大意 输入n,计算出n之内只有0和1组成的数字的数量 分析 k从1开始,只要小于n,就给sum++,并 ...
- C. k-Amazing Numbers 解析(思維)
Codeforce 1417 C. k-Amazing Numbers 解析(思維) 今天我們來看看CF1417C 題目連結 題目 略,請直接看原題. 前言 我實作好慢... @copyright p ...
- SH Script Grammar
http://linux.about.com/library/cmd/blcmdl1_sh.htm http://pubs.opengroup.org/onlinepubs/9699919799/ut ...
- man bash
BASH(1) General Commands Manual BASH(1) NAME bash - GNU Bourne-Again SHell SYNOPSIS bash [options] [ ...
- dhcpd.conf(5) - Linux man page
http://linux.die.net/man/5/dhcpd.conf Name dhcpd.conf - dhcpd configuration file Description The d ...
随机推荐
- oracle 12c新特性 FETCH FIRST、WITH TIES 关键字详解
几乎都是官方文档上的内容. [ OFFSET offset { ROW | ROWS} ] [ FETCH { FIRST | NEXT }[ { rowcount | percent PER ...
- python and pycharm and django 环境配置
python 安装 https://www.python.org/ 我的是win7 32位,下载exe文件傻瓜式安装…… cmd 输入命令 python 则安装成功 如果不能进入,则有可能是环境 ...
- Homebrew 备忘
每次都搜,写篇博客记录以备后续查看. 安装 /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew ...
- JDK8的ConcurrentHashMap也会造成CPU 100%
转载:不止 JDK7 的 HashMap ,JDK8 的 ConcurrentHashMap 也会造成 CPU 100%?原因与解决~ 现象 大家可能都听过JDK7中的HashMap在多线程环境下可能 ...
- Tomcat修改用户名密码教程
Tomcat安装教程见http://www.cnblogs.com/lsdb/p/6497964.html 启动tomcat后访问http://127.0.0.1/:8080,出现界面如下其右上角有三 ...
- npm 安装nodesass 或者包含nodesass的脚手架工具报错问题
由于最近vue转angular 但是angular版本太多了,好多项目是angularv4 有的是v5 近日angular又发布了v6,依赖的东西好多不一样,结果npm install 时候,总是出现 ...
- 外部调用mvc的api方法时,如何解决跨域请求问题?
首先,创建一个mvc项目(包含webapi),我们模拟一个场景 1)在项目的Controller 创建一个WeiXinApiController public class WeiXinApiContr ...
- Matlab、R向量与矩阵操作 z
已有 1849 次阅读 2012-8-2 15:15 |系统分类:科研笔记|关键词:矩阵 480 window border center Matlab.R向量与矩阵操作 描 述 Matla ...
- POJ 1390 Blocks(记忆化搜索+dp)
POJ 1390 Blocks 砌块 时限:5000 MS 内存限制:65536K 提交材料共计: 6204 接受: 2563 描述 你们中的一些人可能玩过一个叫做“积木”的游戏.一行有n个块 ...
- LY.JAVA面向对象编程.内部类
2018-07-18 10:14:48 /* 内部类概述: 把类定义在其他类的内部,这个类就被称为内部类. 举例:在类A中定义了一个类B,类B就是内部类. 内部的访问特点: A:内部类可以直接访问外部 ...