C. Hexadecimal's Numbers
1 second
64 megabytes
standard input
standard output
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 data contains the only number n (1 ≤ n ≤ 109).
Output the only number — answer to the problem.
10
2
For n = 10 the answer includes numbers 1 and 10.
由1 0 组成的数字,就是二进制数字的值!
把当前数字用10表示的最大数字,所代表的二进制的值就是答案。
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<sstream>
#include<algorithm>
#include<queue>
#include<deque>
#include<iomanip>
#include<vector>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<fstream>
#include<memory>
#include<list>
#include<string>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MAXN 503
#define N 33
#define MOD 10000007
#define INF 1000000009
const double eps = 1e-;
const double PI = acos(-1.0);
string str;
int main()
{
cin >> str;
bool f = false;
for (int i = ; i < str.size(); i++)
{
if (f) str[i] = '';
else if (str[i] > '')
{
str[i] = '';
f = true;
}
} LL ans = str[str.size() - ] - '', bas = ;
for (int i = str.size() - ; i >= ; i--)
{
bas *= ;
ans = ans + (str[i] - '')*bas;
}
cout << ans << endl;
return ;
}
C. Hexadecimal's Numbers的更多相关文章
- 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 ...
- Codeforce 9C - Hexadecimal's Numbers
One beautiful July morning a terrible thing happened in Mainframe: a mean virus Megabyte somehow got ...
- 9 C. Hexadecimal's Numbers
题目链接 http://codeforces.com/contest/9/problem/C 题目大意 输入n,计算出n之内只有0和1组成的数字的数量 分析 k从1开始,只要小于n,就给sum++,并 ...
- Codeforces 9C Hexadecimal's Numbers - 有技巧的枚举
2017-08-01 21:35:53 writer:pprp 集训第一天:作为第一道题来讲,说了两种算法, 第一种是跟二进制数联系起来进行分析: 第二种是用深度搜索来做,虽然接触过深度搜索但是这种题 ...
- 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 ...
- bash5.0参考手册
Bash Reference Manual a.summary-letter { text-decoration: none } blockquote.indentedblock { margin-r ...
随机推荐
- Windows8.1查看已连接无线WIFI密码
Windows8.1操作系统下查看已连接无线wifi密码操作步骤如下: 1.右键任务栏中的无线图标,在弹出的菜单中选择"打开网络和共享中心": 2.在网络和共享中心界面中点击&qu ...
- ASP.NET MVC应用程序中支持用户使用腾讯QQ和微信以及新浪微博的第三方登录
什么是第三方授权登录,就是一些大家都会有的帐号如QQ.微信.淘宝.微博等账户.通过那些巨头公司提供的api直接实现登录. 当然,我们是不可能得到你的用户名和密码的.不了解的人,可能会存在这个疑虑.我们 ...
- 260 Single Number III 数组中除了两个数外,其他的数都出现了两次,找出这两个只出现一次的数
给定一个整数数组 nums,其中恰好有两个元素只出现一次,其他所有元素均出现两次. 找出只出现一次的那两个元素.示例:给定 nums = [1, 2, 1, 3, 2, 5], 返回 [3, 5].注 ...
- Redis作者:深度剖析Redis持久化
Redis是一种面向“key-value”类型数据的分布式NoSQL数据库系统,具有高性能.持久存储.适应高并发应用场景等优势.它虽然起步较晚,但发展却十分迅速. 近日,Redis的作者在博客中写到, ...
- Python学习日记之练习代码
# -*- coding:utf-8 -*- number = 23 test=True while test: guess=int(raw_input('输入数字')) if guess==numb ...
- NX自动出图 效果图
- Microsoft SQL Server学习(七)--函数视图
系统函数 视图 索引 1.系统函数 (1) ()数学函数 Abs() 绝对值 Floor() 向下取整 Ceiling() 向上取整 Sin() 返回指定角度(以弧度为单位)的三角正弦值 Pi() 圆 ...
- java 基础学习笔记 - 安装
1. 从www.sun.com中 下载jdk安装包 2. 执行安装包,安装jdk ,jre(Java运行环境) 3. 配置path路径 增加jdk下的bin目录. 配置完后需要重启cmd窗口,因为cm ...
- 【sqli-labs】【jsp/tomcat】 less29 less30 less31 less32 (GET型利用HTTP参数污染的注入)
sqli-labs带了几个Java版本的web注入,在tomcat-files.zip里 以Less29为例,查看源码,可以看出请求最后还是提交给了php应用,难怪less29文件夹下有一个没有任何防 ...
- jdbcTemplate传参使用Map或List
List传参方式 举个例子 sql = "select * from table where id=? and param=?": sql中的参数要用?形式,然后使用list.ad ...