# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
891703 | ind1v | Trol (COCI19_trol) | C++11 | 1 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>
using namespace std;
#define int long long
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define db(x) cout << "[" << #x << "]: " << x << '\n';
int q, s, l, r;
int f(int n) {
if (n % 9 == 0) {
return 9;
}
return (n % 9);
}
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> q;
while (q--) {
cin >> l >> r;
if (l + 100 >= r) {
s = 0;
for (int i = l; i <= r; ++i) {
s += f(i);
}
cout << s << '\n';
} else {
s = 0;
while (f(l) != 1) {
s += f(l);
++l;
}
while (f(r) != 9) {
s += f(r);
--r;
}
s += 45 * (r - l + 1) / 9;
cout << s << '\n';
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |