# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1007335 | vjudge1 | Trol (COCI19_trol) | C++17 | 1095 ms | 348 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int digitSum(int num) {
while (num >= 10) {
int temp = 0;
while (num > 0) {
temp += num % 10;
num /= 10;
}
num = temp;
}
return num;
}
int main() {
int q;
cin >> q;
vector<pair<int, int>> queries(q);
for (int i = 0; i < q; ++i) {
int l, r;
cin >> l >> r;
queries[i] = {l, r};
}
for (int i = 0; i < q; ++i) {
int l = queries[i].first;
int r = queries[i].second;
ll ans = 0;
for (int j = l; j <= r; ++j) {
ans += digitSum(j);
}
cout << ans << endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |