# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
937192 |
2024-03-03T15:39:53 Z |
Omar_G |
Trol (COCI19_trol) |
C++17 |
|
1 ms |
348 KB |
#include <bits/stdc++.h>
using namespace std;
#define Omar_G ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll /*Omar-G*/ long long
#define endl/*Omar-G*/ "\n"
#define ss /*Omar-G*/ string
const ll mod = 1e9 + 7;
void solve() {
ll q;
cin >> q;
while (q--) {
ll l, r;
cin >> l >> r;
l--;
ll a = r - l;
ll ans = (a / 9) * 45;
l = (l % 9) ? l % 9 : 9;
r = (r % 9) ? r % 9 : 9;
if (r >= l) {
ans += (r * (r + 1) / 2) - (l * (l + 1) / 2);
}
else {
ans += (r * (r + 1) / 2) + 45 - (l * (l + 1) / 2);
}
cout << ans << endl;
}
}
void solveT() {ll t; cin >> t; while (t--) solve();}
int main() {
Omar_G
solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |