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 ...
随机推荐
- 【Todo】git的fast forward & git命令学习 & no-ff
git的fast-forward在之前的文章有介绍过,但是介绍的不细: http://www.cnblogs.com/charlesblc/p/5953066.html fast-forward方式就 ...
- 彻底理解javascript 中的事件对象的pageY, clientY, screenY的区别和联系。
说到底, pageY, clientY, screenY的计算,就是要找到参考点, 它们的值就是: 鼠标点击的点----------- 和参考点指点----------的直角坐标系的距离 stacko ...
- [NPM] Set default values for package.json using npm set
Npm by default uses global values when initializing a new package.json file. Learn how to set your o ...
- C++ 学习总结 复习篇
友元的使用 分为友元类和友元函数 //友元类与友元函数的共同点:都可以让某一个类作为另一个类或者函数的参数. //友元类:它让当前类成为另一个类的友元,然后,另一个类 ...
- 使用 Docker 在 Linux 上托管 ASP.NET Core 应用程序
说在前面 在阅读本文之前,您必须对 Docker 的中涉及的基本概念以及常见命令有一定了解,本文侧重实战,不会对相关概念详述. 同时请确保您本地开发机器已完成如下安装: Docker 18.06 或更 ...
- Using Virtual Serial Ports on Linux (Ubuntu)
http://www.xappsoftware.com/wordpress/2013/10/07/using-virtual-serial-ports-on-linux-ubuntu/?goback= ...
- Struts拦截器(转)
xml <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC &qu ...
- 20160222.CCPP体系具体解释(0032天)
程序片段(01):宽字符.c+字符串与内存四区.c 内容概要:宽窄字符 ///宽字符.c #include <stdio.h> #include <stdlib.h> #inc ...
- 【前端】怎样成长为一名优秀的前端project师---
浅谈本人的经验.也算是与大家交流吧,本人眼下也是从事前端的工作,时间并不长,说的不好,请见谅. 首先,前端project师必须得掌握HTML.CSS和JavaScript. 仅仅懂当中一个或两个还不行 ...
- Apache Qpid消息通讯模型和消息地址简介
Broker知识准备 Broker内置两种节点类型:一种是 queue,一种是 topic. 1. queue 节点能够缓存消息,直到被读取走为止.queue节点满足两个重要的 PTP 通信的特征, ...