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 ;
}
最新文章
- jquery触屏幻灯片
- arch下的启动问题解决
- MMORPG大型游戏设计与开发(客户端架构 part11 of vegine)
- import static和import的区别
- 创建表 添加主键 添加列常用SQL语句
- 使用Node.js作为后台进行爬虫
- linux之screen命令
- 【Java数据结构】Java数据结构之链表反转
- ecstore在MySQL5.7下维护报错WARNING:512 @ ALTER IGNORE TABLE
- linux下安装tomcat,并设置自动启动
- JDBC整合c3p0数据库连接池 解决Too many connections错误
- Linux之命令的组合
- vue 添加旋转图片 修改css transform 值
- python 获取当前文件夹下所有文件名
- Asp.Net Core 通过自定义中间件防止图片盗链的实例(转)
- webpack学习笔记-2-file-loader 和 url-loader
- http请求的基本介绍
- 在VS2010中使用Git管理源代码
- 关于 Local feature 和 Global feature 的组合
- 关于Conversion to Dalvik format failed with error 1错误
热门文章
- 数学 Codeforces Round #219 (Div. 2) B. Making Sequences is Fun
- 295 Find Median from Data Stream 数据流的中位数
- jvm内存分区
- Android 简单的语音播报
- 用Python利用pyFirmata控制Arduino实现Blink
- Fiddler 修改响应内容
- CAD使用SetXData写数据(com接口)
- 梦想Android版CAD控件2019.01.23更新
- Spring框架系列(九)--MyBatis面试题(转载)
- ThinkPHP---TP拓展之获取IP信息