# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
937192 | Omar_G | Trol (COCI19_trol) | C++17 | 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 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 |
---|---|---|---|---|
Fetching results... |