-
Notifications
You must be signed in to change notification settings - Fork 67
/
ADAKOHL.cpp
47 lines (39 loc) · 976 Bytes
/
ADAKOHL.cpp
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
40
41
42
43
44
45
46
47
//
// main.cpp
// practice
//
// Created by Mahmud on 9/13/17.
// Copyright © 2017 Mahmud. All rights reserved.
//
/*
Think what happens when you append a new digit.
Suffix sums change and it can be easily handled in DP.
*/
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <ctime>
using namespace std;
const int MAX = 2000005;
const int modulo = 1000000007;
int N;
char ch;
int s[MAX];
int f[MAX], suffix[MAX];
int main(int argc, const char * argv[]) {
/*
f[n] = f[n - 1] + n * data[i] + suffix_sum[n - 1] * 10
suffix_sum[n] = suffix_sum[n - 1] * 10 + n * data[i]
*/
while((ch = getchar_unlocked()) != '\n') {
s[++N] = ch - '0';
}
for (int i = 1; i <= N; i ++) {
f[i] = (f[i - 1] + i * s[i] + 10LL * suffix[i - 1] % modulo) % modulo;
suffix[i] = (10LL * suffix[i - 1] % modulo + i * s[i]) % modulo;
}
cout << f[N] << endl;
return 0;
}