-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCF1932E.cpp
33 lines (33 loc) · 830 Bytes
/
CF1932E.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
#include <bits/extc++.h>
using namespace std;
namespace pbds = __gnu_pbds;
using ui = unsigned int;
using uli = unsigned long long int;
using li = long long int;
using uc = unsigned char;
int main(void) {
ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
size_t T;
cin >> T;
while (T--) {
size_t n;
cin >> n;
vector<ui> s(n);
for (ui& i : s) {
char c;
cin >> c;
i = c - '0';
}
vector<uli> ans(n);
partial_sum(s.cbegin(), s.cend(), ans.begin());
for (size_t i = n - 1; i > 0; --i) ans[i - 1] += ans[i] / 10, ans[i] %= 10;
vector<uli>::const_iterator it = ans.begin();
while (it < ans.end() && *it == 0) ++it;
if (it == ans.end())
cout.put('0');
else
for (; it < ans.end(); ++it) cout << *it;
cout.put('\n');
}
return 0;
}