# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1255114 | opitu | Trol (COCI19_trol) | C++20 | 1 ms | 328 KiB |
#include <bits/stdc++.h>
using namespace std;
int main() {
vector<int> a = {9, 1, 2, 3, 4, 5, 6, 7, 8};
vector<int> p(10, 0), s(10, 0);
for (int i = 1; i <= 9; i++) p[i] = p[i-1] + a[i-1];
for (int i = 8; i >= 0; i--) s[i] = s[i+1] + a[i];
int t; cin >> t; while (t--) {
long long l, r; cin >> l >> r;
long long gap = r/9-(l+8)/9;
long long ans = 45*gap;
cout << s[l%9]%45 + ans + p[r%9+1] << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |