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

今天药忘吃喽~ 2022-01-09 06:07 311阅读 0赞

题目传送门

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

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

发表评论

表情:
评论列表 (有 0 条评论,311人围观)

还没有评论,来说两句吧...

相关阅读