-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathC.cpp
More file actions
39 lines (31 loc) · 868 Bytes
/
Copy pathC.cpp
File metadata and controls
39 lines (31 loc) · 868 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <bits/stdc++.h>
using namespace std;
#define long long long int
#define err(a...) fprintf(stderr, a)
constexpr int M = 1000 * 1000 * 1000 + 7;
int power(int n, int x) {
int res = 1;
for ( ; x; x >>= 1, n = 1ll * n * n % M)
if (x & 1) res = 1ll * res * n % M;
return res;
}
constexpr int N = 1e5 + 10;
char s[N];
int f[N];
int main() {
scanf("%s", s);
int n = strlen(s);
reverse(s, s + n);
for (int i = 0; i < n; ++i) {
if (i > 0) f[i] = f[i - 1];
(f[i] += 1ll * power(10, i) * (i + 1) % M) %= M;
}
int ans = 0;
for (int i = 0; i < n; ++i) {
int c = (int) (s[i] - '0');
if (i > 0) (ans += 1ll * f[i - 1] * c % M) %= M;
if (i < n - 1) (ans += 1ll * (1ll * c * power(10, i) % M) * (1ll * (n - i - 1) * (n - i) / 2 % M) % M) %= M;
}
printf("%d", ans);
return 0;
}