#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
int main() {
int q;
cin >> q;
auto query = [&](ull p) {
if(!p) return 0ull;
int full = p / 9;
ull ans = full * 45;
for(ull i=full*9+1; i<=p; i++) ans += i % 9;
return ans;
};
while(q--) {
ull l, r;
cin >> l >> r;
cout << query(r) - query(l-1) << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Execution timed out |
1091 ms |
348 KB |
Time limit exceeded |
4 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
5 |
Execution timed out |
1085 ms |
348 KB |
Time limit exceeded |