codeforce 9C 找规律的思维题
来源:互联网 发布:新少林五祖 知乎 编辑:程序博客网 时间:2024/06/05 22:42
http://vjudge.net/contest/view.action?cid=47681#problem/C
Description
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.
Sample Input
10
2
Hint
For n = 10 the answer includes numbers 1 and 10.
注意其实数据范围是1~10^10,,,题干描述不准确,我被骗wa了一次==
#include <stdio.h>#include <string.h>#include <iostream>#include <algorithm>using namespace std;char a[10];int sum[11]={0,1,2,4,8,16,32,64,128,256,512};int main(){ while(~scanf("%s",a+1)) { int n=strlen(a+1); int sum1=0; for(int i=1;i<=n;i++) { if(a[i]>'1') { for(int j=1;j<=n-i+1;j++) sum1+=sum[j]; break; } if(a[i]=='1') sum1+=sum[n-i+1]; } printf("%d\n",sum1); } return 0;}
- codeforce 9C 找规律的思维题
- codeforce(找规律的简单题)
- Codeforce 424C Magic Formulas 找规律
- codeforces-141【B找规律】【C思维】
- codeforces-743【B找规律】C思维】
- Kolakoski(思维+找规律)
- Codeforce 424C(规律)
- codeforce 632 前三题 找规律,暴力,字符串
- 思维、找规律题目汇总
- HDU 6048 思维+找规律
- 一道找规律的题
- poj 1019 Number Sequence 找规律 思维题 ()
- cfdiv2/c/找规律
- codeforce 796 c Bank Hacking (思维题,分类讨论)
- UESTC 1012 (思维)(找规律)
- Beehive UVALive - 7528 (找规律+数学思维)
- hdu4572_Bottles Arrangement_(思维+找规律)
- codeforce 259B 第二场 最新题解 (找规律)
- Objective C Foundation框架(NSString)
- UIApplication代理简介
- codeforce 9A
- 对《C和指针》及《编码:藏匿在计算机软硬件背后的语言》两本书籍的看法
- 最短路算法
- codeforce 9C 找规律的思维题
- Java异常处理终结篇——如何进行Java异常处理设计
- POJ 3680 Intervals
- 十大要避免的Ext JS开发方法
- 设计模式——三大工厂模式
- 【Espruino】NO.09 使用SPI操作Sharp Memory LCD
- 29岁为什么还那么短视呢?
- Swift Research Link
- 使用支付宝 手机转账服务 收款只要回短信