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 ...
随机推荐
- php面向对象比较
在PHP中有 = 赋值符号.== 等于符号 和 === 全等于符号, 这些符号代表什么意思? (1).=是赋值符 (2).使用 == 符号比较两个对象 ,比较的仅仅是两个对象的内容是否一致. (3). ...
- leetcode-algorithms-2 Add Two Numbers
leetcode-algorithms-2 Add Two Numbers You are given two non-empty linked lists representing two non- ...
- poj2117-tarjin求割点
http://poj.org/problem?id=2117 求移除一个点以及与它相邻边后,剩下的图中最大的联通子图的数量是多少. 跑一遍tarjin统计下拆除某个点剩下的子图数量即可.注意给出的图不 ...
- oracle 如何创建只有查询权限的用户
.create user userName identified by password; .grant select any table to userName; --授予查询任何表 .grant ...
- [每周一文]week 1
花开人间四月天 摘自美文网:https://www.lookmw.cn/xinqing/49623.html 赏春 四月芳菲淡淡香,寻花问柳向斜阳. 陌上行人思作客,人间遍地是春情. 文/ ...
- 两个有序数组的中位数(第k大的数)
问题:两个已经排好序的数组,找出两个数组合并后的中位数(如果两个数组的元素数目是偶数,返回上中位数). 感觉这种题目挺难的,尤其是将算法完全写对.因为当初自己微软面试的时候遇到了,但是没有想出来思路. ...
- Qt Widgets——抽象按钮及其继承类
QAbstractButton是有关“按钮”的基类 描述了一个按钮应该具有的组成.它的公有函数如下: QAbstractButton(QWidget * parent = ) ~QAbstractBu ...
- git报错fatal: I don't handle protocol 'https'处理
一.背景说明 今天使用在Cygwin中git clone时报fatal: I don't handle protocol 'https',如下: 以为是Cygwin实现的git有点问题没太在意,换去 ...
- linux ssh root登陆出现错误:Permission denied, please try again
密码已检测过多遍还是登录失败 经检查 vim /etc/ssh/sshd_config PermitRootLogin no 改成 PermitRootLogin yes 修改之后重启就可以了
- CF712E [Memort and Casinos]
题意 每次询问一段区间[l,r],求从最左边走到最右边(r+1)的概率(若走到l-1,则GG了),每个点上写有向右走的概率.支持单点修改. 思考 若只查询一次,那只要知道每个点在不走到l-1的情况下, ...