B. Vanya and Books
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard 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.
InputThe first line contains integer n (1 ≤ n ≤ 109) — the number of books in the library.
OutputPrint the number of digits needed to number all the books.
Examplesinput13output17input4output4NoteNote 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共出现了多少个数字。
附AC代码:
#include<bits/stdc++.h>
using namespace std; int main(){
int n;
cin>>n;
long long ans=,sum=;
while(n-ans>=){
sum+=n-ans+;
ans*=;
}
cout<<sum<<endl;
return ;
}
B. Vanya and Books的更多相关文章
- Codeforces Round #308 (Div. 2)B. Vanya and Books 数学
B. Vanya and Books Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/552/pr ...
- B. Vanya and Books( Codeforces Round #308 (Div. 2) 简单题)
B. Vanya and Books time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- 数学 Codeforces Round #308 (Div. 2) B. Vanya and Books
题目传送门 /* 水题:求总数字个数,开long long竟然莫名其妙WA了几次,也没改啥又对了:) */ #include <cstdio> #include <iostream& ...
- 【33.33%】【codeforces 552B】Vanya and Books
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- #308 (div.2) B. Vanya and Books
1.题目描写叙述:点击打开链接 2.解题思路:本题要求统计数位的个数,简单的试验一下发现有例如以下规律:一个n位数的个数有9*(10^n)个.因此全部n位数的数位是n*9*(10^n)个.因此能够利用 ...
- Codeforces Round #308 (Div. 2) A B C 水 数学
A. Vanya and Table time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #308 (Div. 2)
A. Vanya and Table Vanya has a table consisting of 100 rows, each row contains 100 cells. The rows ...
- codeforces C. Vanya and Scales
C. Vanya and Scales Vanya has a scales for weighing loads and weights of masses w0, w1, w2, ..., w10 ...
- 7 Must Read Python Books
7 Must Read Python Books I started learning Python just two years ago. Coming from a C++ and Java ba ...
随机推荐
- Activiti 5.17 实体对象与类和数据库表的映射
一.Activiti 5.17 mybatis的mapping文件声明映射的实体对象关系. <configuration><settings><settingname=& ...
- BUPT复试专题—List(2015)
题目描述 在该LIST上实现3种操作 1.append x在该LIST末尾添加x,x是32位整数 2.pop删除该LIST末尾的数 3.find i寻找第i个数,若i为负数表示寻找倒数第i个数,例如i ...
- SolidEdge 工程图中如何绘制中断视图
右击长条形的视图,点击新增断裂线,然后绘制两个断点 点击完成之后效果如下图所示 如果要修改断裂视图的样式,则选中这个视图,在左键单击,然后点击这个按钮取消显示断裂视图 然后左键单击断裂视图 ...
- react 创建组件 (四)Stateless Functional Component
上面我们提到的创建组件的方式,都是用来创建包含状态和用户交互的复杂组件,当组件本身只是用来展示,所有数据都是通过props传入的时候,我们便可以使用Stateless Functional Compo ...
- HDU 1398 Square Coins(母函数或dp)
Square Coins Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tota ...
- Python——类的高级主题
介绍关于类的一些高级主题,这些是可选的,在Python应用程序中,不会常常遇到. =========================================================== ...
- snip_进制转换代码段
10进制转成16进制. /* 程序:10进制转16进制的C语言实现 描述: 关键: 获得余 获得整 整为零 则退出 */ #include<stdio.h> #define N 10 #d ...
- JOIN ,LEFT JOIN ,ALL JOIN 等的区别和联系
left join(左联接) 返回包括左表中的所有记录和右表中联结字段相等的记录 right join(右联接) 返回包括右表中的所有记录和左表中联结字段相等的记录 inner join(等值连接) ...
- UVa 12587 Reduce the Maintenance Cost(Tarjan + 二分 + DFS)
题意:n个城市(n <= 10000), 有m条边(m <= 40000),每一个城市有一个维护费用Cost(i),除此之外,每条边的维修费用为去掉该边后不能通信的城市对数与边权的积.这个 ...
- WebGIS中地图恢复初始位置及状态
我想实现这么一个效果:地图任意缩放后,点击一个按钮,将立刻回到地图初始加载时的位置,并且是没有缩放的状态. 怎么办呢?最好的办法就是用Home按钮. <!DOCTYPE HTML> < ...