水题

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.

Example
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之中有多少个数字。

题解:找规律。

#include<stdio.h>
#include<string.h>
int main()
{
    long long i,n;
    scanf("%lld",&n);
    if(n<10)
    {
        i=n;
    }
    else if(n>9&&n<100)
    {
        i=2*n-9;
    }
    else if(n>99&&n<1000)
    {
        i=3*n-108;
    }
    else if(n>999&&n<10000)
    {
        i=4*n-1107;
    }
    else if(n>9999&&n<100000)
    {
        i=5*n-11106;
    }
    else if(n>99999&&n<1000000)
    {
        i=6*n-111105;
    }
    else if(n>999999&&n<10000000)
    {
        i=7*n-1111104;
    }
    else if(n>9999999&&n<100000000)
    {
        i=n*8-11111103;
    }
    else if(n>99999999&&n<1000000000)
    {
        i=9*n-111111102;
    }
    else if(n==1000000000)
    {
        i=10*n-1111111101;
    }
    printf("%lld",i);
    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值