B. Vanya and Books

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://codeforces.com/contest/552/problem/B

Description

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 Input

13

Sample Output

17

HINT

题意

要写n个数,然后问你一个写了多少个数字

比如17这个数,就写了2个数字

题解:

数学题,每一位都是9*10^n个

代码:

#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define test freopen("test.txt","r",stdin)
#define maxn 1000010
#define mod 1000000007
#define eps 1e-6
const int inf=0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
//************************************************************************************** int main()
{
ll n=read();
ll i=;
ll k=;
ll ans=;
while(n>=i)
{
n-=i;
ans+=i*k;
k++;
i=i*;
}
ans+=n*k;
cout<<ans<<endl;
}

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

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

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

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

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

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

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

  4. 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 ...

  5. Codeforces Round #308 (Div. 2) D. Vanya and Triangles 水题

    D. Vanya and Triangles Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/55 ...

  6. Codeforces Round #308 (Div. 2) C. Vanya and Scales dfs

    C. Vanya and Scales Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/552/p ...

  7. Codeforces Round #308 (Div. 2) A. Vanya and Table 暴力

    A. Vanya and Table Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/552/pr ...

  8. Codeforces Round #308 (Div. 2)----C. Vanya and Scales

    C. Vanya and Scales time limit per test 1 second memory limit per test 256 megabytes input standard ...

  9. Codeforces Round #280 (Div. 2) E. Vanya and Field 数学

    E. Vanya and Field Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/492/pr ...

随机推荐

  1. Solution multisite htaccess cleanURL

    My solution to getting Clean URL working with my multisite setup drupal 4.7 I added Alias to my http ...

  2. Python函数练习:冒泡算法+快速排序(二分法)

    冒泡算法: #-*- coding: UTF-8 -*-#冒泡排序 def func(lt):if type(lt).__name__ !='list' and type(lt).__name__ ! ...

  3. selenium python (十)浏览器多窗口处理

    #!/usr/bin/python# -*- coding: utf-8 -*-__author__ = 'zuoanvip'#在测试过程中有时候会遇到出现多个浏览器窗口的情况,这时候我们可以通过窗口 ...

  4. java 获取当前时间及年月日时分秒

    java代码如下: package test; import java.text.SimpleDateFormat; import java.util.Calendar; import java.ut ...

  5. 【Unity入门】碰撞检测与触发检测

    版权声明:本文为博主原创文章,转载请注明出处. 在Unity里面,游戏物体的碰撞我们可以通过刚体组件(Rigidbody)和碰撞器组件(Collider)来进行检测.首先在场景里面添加一个Plane面 ...

  6. Cassandra + Eclipse + Hadoop

    配置好eclipse连接hadoop: 参考:http://www.powerxing.com/hadoop-build-project-using-eclipse/ http://blog.csdn ...

  7. Web 检测代码 web analysis 开源 open source

    1. Grape Web Statistics Grape Web Statistics is a fairly simple piece of analytics software. Grape i ...

  8. dom div重合提示

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  9. Spark RDD概念学习系列之RDD的操作(七)

    RDD的操作 RDD支持两种操作:转换和动作. 1)转换,即从现有的数据集创建一个新的数据集. 2)动作,即在数据集上进行计算后,返回一个值给Driver程序. 例如,map就是一种转换,它将数据集每 ...

  10. MSSQL手札四 MSSQL的函数

    和oracle一样,sql也可以自己定义函数 一个返回值,引用DEMO如下: 编写一个函数,该函数,可以通过输入借书时间来判断是否到期,当借阅时间大于30天,返回已经过期:否则返回还未到期. CREA ...