-
Notifications
You must be signed in to change notification settings - Fork 184
/
Copy pathd1.cc
41 lines (38 loc) · 785 Bytes
/
d1.cc
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
// https://codeforces.com/contest/1195/problem/D1
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
const ll M = 998244353;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
ll n, x;
cin >> n;
vvi d (n);
for (int i = 0; i < n; i++) {
cin >> x;
while (x) {
d[i].push_back(x % 10);
x /= 10;
}
}
ll s = 0;
for (int i = 0; i < n; i++) {
ll m = 1;
for (int j = 0; j < d[i].size(); j++) {
ll x = (n * d[i][j]) % M;
x = (x * m) % M;
s = (s + x) % M;
if (s < 0) s += M;
m = (m * 10) % M;
x = (n * d[i][j]) % M;
x = (x * m) % M;
s = (s + x) % M;
if (s < 0) s += M;
m = (m * 10) % M;
}
}
cout << s << "\n";
}