# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
934292 |
2024-02-27T06:24:38 Z |
Khasar |
Trol (COCI19_trol) |
C++14 |
|
1 ms |
444 KB |
#include <bits/stdc++.h>
using namespace std;
int q;
long long l, r;
long long sum1(int a, int b) {
return (a + b) * (b - a + 1) / 2;
}
long long sum(long long x) {
long long t = x / 9;
x %= 9;
return sum1(1, 9) * t + sum1(1, x);
}
int main() {
cin >> q;
while (q--) {
cin >> l >> r;
cout << sum(r) - sum(l - 1) << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
444 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |