# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
977187 | vjudge1 | 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 ll long long
#define endl '\n'
#define debug(x) cerr << #x << " --> " << x << endl;
#define shine ios_base::sync_with_stdio(false), cin.tie(nullptr);
const ll mod = 1e9 + 7;
const ll inf = 1e18;
int main(){
shine
ll q;
cin >> q;
while(q--){
ll l, r;
cin >> l >> r;
l--;
ll cnt1 = (r / 9), cnt2 = (l / 9), mod1 = r % 9, mod2 = l % 9;
ll ans = 45*(cnt1 - cnt2) + ((mod1*(mod1+1)-(mod2*(mod2+1))) >> 1);
cout << ans << endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |