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 ...
 
随机推荐
- 虽然今天angular5发布了,但我还是吧这篇angularjs(1)+webpack的文章发出来吧哈哈哈
			
本文为原创,转载请注明出处: cnzt 文章:cnzt-p http://www.cnblogs.com/zt-blog/p/7779384.html 写在前面: 因为最近总结自己之前做过 ...
 - 利用背景流量数据(contexual flow data) 识别TLS加密恶意流量
			
识别出加密流量中潜藏的安全威胁具有很大挑战,现已存在一些检测方法利用数据流的元数据来进行检测,包括包长度和到达间隔时间等.来自思科的研究人员扩展现有的检测方法提出一种新的思路(称之为“dataomni ...
 - 转:为什么Uber宣布从Postgres切换到MySQL?
			
转: http://mp.weixin.qq.com/s?__biz=MzAwMDU1MTE1OQ==&mid=2653547609&idx=1&sn=cbb55ee823dd ...
 - groovy入门 第05章 基本输入输出
			
基本输入输出 5.1基本输出 print XXX //同一行输出 println XXX //换行输出 输出字符串: def message ="My name is Michael& ...
 - HDOJ 5091 Beam Cannon 扫描线
			
线段树+扫描线: 我们用矩形的中心点来描写叙述这个矩形,然后对于每一个敌舰,我们建立一个矩形中心的活动范围,即矩形中心在该范围内活动就能够覆盖到该敌舰.那么我们要求的问题就变成了:随意一个区域(肯定也 ...
 - Metasploit学习笔记之——情报搜集
			
1.情报搜集 1.1外围信息搜索 1.1.1通过DNS和IP地址挖掘目标网络信息 (1)whois域名注冊信息查询(BT5.kali专有):root@kali:~# whois testfire.ne ...
 - 关于HTTP1.1的长连接
			
HTTP是一个构建在传输层的TCP协议之上的应用层的协议,在这个层的协议,是一种网络交互须要遵守的一种协议规范. HTTP1.0的短连接 HTTP 1.0规定浏览器与server仅仅保持短暂的连接.浏 ...
 - hibernate预编译SQL语句中的setParameter和setParameterList
			
使用预编译SQL语句和占位符參数(在jdbc中是?),可以避免由于使用字符串拼接sql语句带来的复杂性.我们先来简单的看下.使用预编译SQL语句的优点. 使用String sql = "se ...
 - Docker and Go: why did we decide to write Docker in Go?
			
Docker and Go: why did we decide to write Docker in Go? | Hacker News https://news.ycombinator.com/i ...
 - TButton.Repaint的执行过程
			
测试,在按钮事件里写上 Button1.Repaint;(包括TWinControl.Invalidate;和procedure TWinControl.Update;两个函数,会被TButton所继 ...