B. Vanya and Books
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Vanya got an important task — he should enumerate books in the library and label each book with its number. Each of the n books should
be assigned with a number from 1 to n.
Naturally, distinct books should be assigned distinct numbers.

Vanya wants to know how many digits he will have to write down as he labels the books.

Input

The first line contains integer n (1 ≤ n ≤ 109)
— the number of books in the library.

Output

Print the number of digits needed to number all the books.

Sample test(s)
input
13
output
17
input
4
output
4
Note

Note to the first test. The books get numbers 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, which totals to 17 digits.

Note to the second sample. The books get numbers 1, 2, 3, 4, which totals to 4 digits.

题意:为1-n之中有多少个数字。比如10有两个数字。100有三个数字。

点击打开链接

#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
#include<stdlib.h> using namespace std; __int64 sum;
__int64 a[] = {0,9,90,900,9000,90000,900000,9000000,90000000,900000000};
__int64 b[] = {0,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000,10000000000};
__int64 n; int main(){
while(scanf("%I64d",&n)!=EOF){
sum = 0;
for(int i=1;i<=10;i++){
if(n>=b[i]){
sum += a[i]*i;
}else{
sum += (n - b[i-1] + 1)*i;
break;
}
}
if(n<10)
{
sum--;
}
printf("%I64d\n",sum);
}
}

B. Vanya and Books( Codeforces Round #308 (Div. 2) 简单题)的更多相关文章

  1. B. Simple Game( Codeforces Round #316 (Div. 2) 简单题)

    B. Simple Game time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  2. B. Case of Fake Numbers( Codeforces Round #310 (Div. 2) 简单题)

    B. Case of Fake Numbers time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  3. 数学 Codeforces Round #308 (Div. 2) B. Vanya and Books

    题目传送门 /* 水题:求总数字个数,开long long竟然莫名其妙WA了几次,也没改啥又对了:) */ #include <cstdio> #include <iostream& ...

  4. 水题 Codeforces Round #308 (Div. 2) A. Vanya and Table

    题目传送门 /* 水题:读懂题目就能做 */ #include <cstdio> #include <iostream> #include <algorithm> ...

  5. 暴力/进制转换 Codeforces Round #308 (Div. 2) C. Vanya and Scales

    题目传送门 /* 题意:问是否能用质量为w^0,w^1,...,w^100的砝码各1个称出重量m,砝码放左边或在右边 暴力/进制转换:假设可以称出,用w进制表示,每一位是0,1,w-1.w-1表示砝码 ...

  6. Codeforces Round #378 (Div. 2) D题(data structure)解题报告

    题目地址 先简单的总结一下这次CF,前两道题非常的水,可是第一题又是因为自己想的不够周到而被Hack了一次(或许也应该感谢这个hack我的人,使我没有最后在赛后测试中WA).做到C题时看到题目情况非常 ...

  7. Codeforces Round #612 (Div. 2) 前四题题解

    这场比赛的出题人挺有意思,全部magic成了青色. 还有题目中的图片特别有趣. 晚上没打,开virtual contest打的,就会前三道,我太菜了. 最后看着题解补了第四道. 比赛传送门 A. An ...

  8. Codeforces Round #552 (Div. 3) A题

    题目网址:http://codeforces.com/contest/1154/problem/ 题目意思:就是给你四个数,这四个数是a+b,a+c,b+c,a+b+c,次序未知要反求出a,b,c,d ...

  9. Codeforces Round #713 (Div. 3)AB题

    Codeforces Round #713 (Div. 3) Editorial 记录一下自己写的前二题本人比较菜 A. Spy Detected! You are given an array a ...

随机推荐

  1. mac MyEclipse2017 CI10安装破解心得

    前段时间也不知弄了什么东西把之前的me弄坏了,于是看看新版本的情况,准备安装个新版本,一看出了ci10,安装之. 破解资源请到这里下载 https://download.csdn.net/downlo ...

  2. JAX-WS文章汇总

    学习路线图 传送门 最简单的Web Service实现- 这里提供一个最简单的Web Service的实现,基于JAX-WS.除了jdk不需要任何其他jar包,使用Eclipse提供的Web Serv ...

  3. 洛谷——P1618 三连击(升级版)

    P1618 三连击(升级版) 题目描述 将1,2,…,9共9个数分成三组,分别组成三个三位数,且使这三个三位数的比例是A:B:C,试求出所有满足条件的三个三位数,若无解,输出“No!!!”. //感谢 ...

  4. Xamarin 中Visual Studio创建项目提示错误

    Xamarin 中Visual Studio创建项目提示错误 错误信息:Object reference not set to an instance of an object 出现这种情况,是由于没 ...

  5. Standard - 多线程基本概念面试题待整理

    http://blog.csdn.net/dazhong159/article/details/7948327 http://z-jiankun.iteye.com/blog/1408471 http ...

  6. HZAU 1201 Friends(树形DP)

    [题目链接] http://acm.hzau.edu.cn/problem.php?id=1201 [题目大意] 给出一棵树,问每个节点距离六个点以内的点有几个 [题解] 定根维护树形DP,Dw[x] ...

  7. 【构造】Tinkoff Challenge - Final Round (Codeforces Round #414, rated, Div. 1 + Div. 2) D. Labelling Cities

    考试的时候想的是,将所有的完全子图缩起来,然后如果剩下的是一条链,依次对其进行标号即可. 看了官方题解,发现完全子图这个条件太强了,缩点的条件仅仅需要保证原本两个点的“邻接表”相同即可.(注意这里的“ ...

  8. React事件系统入门

    React基于虚拟DOM实现了一个合成事件层,我们所定义的事件处理器会接受到一个合成事件层对象的实例,它完全符合W3C标准,不会存在任何IE标准的兼容性问题.并且和原生的浏览器事件一样拥有同样的接口, ...

  9. 防止xss攻击

    <?php function _removeXSS($val) { $search = 'abcdefghijklmnopqrstuvwxyz'; $search .= 'ABCDEFGHIJK ...

  10. 自定义Cell引发的悲剧。。。。

    这两天毕设,昨晚微调自定义的cell,之前用mrc的时候直接打开xib布局好自定义cell就行乐,不用去勾选Use Autolayout,可是昨晚开始,自定义cell中,label不能动态调高的问题, ...