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 ... 
随机推荐
- Oracle11g温习-第十四章:约束(   constraint )
			2013年4月27日 星期六 10:48 1.约束的功能 通过一些强制性商业规则,保证数据的完整性.一致性 2.约束的类别 1 ) not null 不允许为空 2 ) check ... 
- Hadoop设置任务执行队列及优先级
			Hive设置方法: SET mapreduce.job.queuename=root.up; SET mapreduce.job.priority=HIGH; set tez.queue.name=c ... 
- 【转】js生成接口请求参数签名加密
			js生成接口请求参数签名加密 签名算法规则: 第一步,设所有发送或者接收到的数据为集合M,将集合M内非空参数值的参数按照参数名ASCII码从小到大排序(字典序),使用URL键值对的格式(即key1=v ... 
- [LeetCode] 94. Binary Tree Inorder Traversal(二叉树的中序遍历) ☆☆☆
			二叉树遍历(前序.中序.后序.层次.深度优先.广度优先遍历) 描述 解析 递归方案 很简单,先左孩子,输出根,再右孩子. 非递归方案 因为访问左孩子后要访问右孩子,所以需要栈这样的数据结构. 1.指针 ... 
- java 类变量初始化顺序
			假定有一个类定义如下: package com.zhang; public final class Girl { // static代码块1 private static String sex = & ... 
- weblogic启动比一般机器慢原因
			weblogic启动慢一般先看setDomainEnv.sh中分配给JVM的内存大小,如果分配足够(没部应用一般也要1G以上)那么再用free -g看本机剩余内存是否充足.如果都没问题还是比一般机器启 ... 
- 消费Restful的web服务(三)
			构架工程 创建一个springboot工程,去消费RESTFUL的服务.这个服务是 http:///gturnquist-quoters.cfapps.io/api/random ,它会随机返回Jso ... 
- ID基本操作(标尺,参考线,网格)5.11
			参考线:标尺参考线,分栏参考线,出血参考线.在创建参考线之前确保标尺和参考线都可见.并且选中正确的跨页和页面作为目标, “版面”“创建参考线”可以输入数值创建参考线. 跨页参考线的创建:拖动参考线时鼠 ... 
- 序列(SEQUENCE)
			序列(SEQUENCE)是序列号生成器,可以为表中的行自动生成序列号,产生一组等间隔的数值(类型为数字).其主要的用途是生成表的主键值,可以在插入语句中引用,也可以通过查询检查当前值,或使序列增至下一 ... 
- 使用laravel搭建CURD后台页面
			配置即一切 一切皆于需求,后台从0开始搭建,但是写了一两个页面后发现太多的是对单表的增删改查操作,于是就想到了,能不能做一个快速搭建的后台.想到一句话,配置即一切.如果一个CURD后台能只进行配置就自 ... 
