数学 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 }
时间: 2024-11-16 12:14:51

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

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

题目传送门 1 /* 2 题意:问是否能用质量为w^0,w^1,...,w^100的砝码各1个称出重量m,砝码放左边或在右边 3 暴力/进制转换:假设可以称出,用w进制表示,每一位是0,1,w-1.w-1表示砝码与物品放在一起,模拟判断每位是否ok 4 详细解释:http://blog.csdn.net/u011265346/article/details/46556361 5 总结:比赛时压根没往进制去想,连样例也不知道是怎么回事..中文不行啊:( 6 */ 7 #include <cstdi

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

题目传送门 1 /* 2 水题:读懂题目就能做 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

贪心/数学 Codeforces Round #212 (Div. 2) A. Two Semiknights Meet

题目传送门 1 /* 2 贪心/数学:还以为是BFS,其实x1 + 4 * k = x2, y1 + 4 * l = y2 3 */ 4 #include <cstdio> 5 #include <algorithm> 6 #include <cstring> 7 using namespace std; 8 9 const int MAXN = 11; 10 const int INF = 0x3f3f3f3f; 11 char s[MAXN][MAXN]; 12 1

数学 Codeforces Round #219 (Div. 2) B. Making Sequences is Fun

题目传送门 1 /* 2 数学:这题一直WA在13组上,看了数据才知道是计算cost时超long long了 3 另外不足一个区间的直接计算个数就可以了 4 */ 5 #include <cstdio> 6 #include <cmath> 7 #include <iostream> 8 #include <algorithm> 9 #include <cstring> 10 using namespace std; 11 12 typedef

数学 Codeforces Round #282 (Div. 2) B. Modular Equations

题目传送门 题意:a % x == b,求符合条件的x有几个 数学:等式转换为:a == nx + b,那么设k = nx = a - b,易得k的约数(>b)的都符合条件,比如a=25 b=1,那么24,12, 8, 6, 4, 3, 2都可以,所以只要求出k的约数有几个就可以了,a <= b的情况要特判 /************************************************* Author        :Running_Time* Created Time  

Codeforces Round #308 (Div. 2)

A. Vanya and Table Vanya has a table consisting of 100 rows, each row contains 100 cells. The rows are numbered by integers from 1 to 100 from bottom to top, the columns are numbered from 1 to 100 from left to right. In this table, Vanya chose n rect

2017-4-23-Train:Codeforces Round #308 (Div. 2)

A. Vanya and Table(思考) Vanya has a table consisting of 100 rows, each row contains 100 cells. The rows are numbered by integers from 1 to 100 from bottom to top, the columns are numbered from 1 to 100 from left to right. In this table, Vanya chose n 

Codeforces Round #355 (Div. 2) D. Vanya and Treasure 分治暴力

D. Vanya and Treasure Vanya is in the palace that can be represented as a grid n?×?m. Each room contains a single chest, an the room located in the i-th row and j-th columns contains the chest of type aij. Each chest of type x?≤?p?-?1 contains a key

#308 (div.2) B. Vanya and Books

1.题目描述:点击打开链接 2.解题思路:本题要求统计数位的个数,简单的试验一下发现有如下规律:一个n位数的个数有9*(10^n)个,因此所有n位数的数位是n*9*(10^n)个,因此可以利用两个循环变量base,k来计算,其中base表示n位数的总个数,k表示每一个n位数的数位有k位,循环条件是n-base>0,这样即可完成统计. 3.代码: #define _CRT_SECURE_NO_WARNINGS #include<iostream> #include<algorithm