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

 

题目传送门

 1 /*
 2     水题:求总数字个数,开long long竟然莫名其妙WA了几次,也没改啥又对了:)
 3 */
 4 #include <cstdio>
 5 #include <iostream>
 6 #include <algorithm>
 7 #include <cstring>
 8 #include <cmath>
 9 #include <vector>
10 #include <string>
11 #include <queue>
12 #include <map>
13 #include <set>
14 using namespace std;
15 
16 typedef long long ll;
17 const int MAXN = 1e2 + 10;
18 const int INF = 0x3f3f3f3f;
19 
20 int main(void)      //Codeforces Round #308 (Div. 2) B. Vanya and Books
21 {
22     // freopen ("B.in", "r", stdin);
23 
24     ll n;
25     while (scanf ("%I64d", &n) == 1)
26     {
27         int len = 0;    ll tmp = n;
28         while (tmp)
29         {
30             tmp /= 10;    len++;
31         }
32 
33         ll ans = 0;    ll x = 9;
34         for (int i=1; i<=len-1; ++i)
35         {
36             ans += x * i;    x *= 10;
37         }
38         ll y = 1;
39         for (int i=1; i<=len-1; ++i)    y *= 10;
40 
41         ans += (n - y + 1) * len;
42         printf ("%I64d\n", ans);
43     }
44 
45 
46     return 0;
47 }

 

转载于:https://www.cnblogs.com/Running-Time/p/4588200.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值