# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
251447 | terencehill | Trol (COCI19_trol) | C++14 | 1 ms | 256 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>
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define P 1000000007
#define in(x, a, b) (a <= x && x < b)
using namespace std;
using ll = long long;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
const ll inf = 1000000001, INF = (ll)1e18 + 1;
int main() {
// freopen("INSERT_NAME_HERE.in", "r", stdin);
// freopen("INSERT_NAME_HERE.out", "w", stdout);
int q;
cin >> q;
while(q--) {
ll l, r;
cin >> l >> r;
ll ans = 0;
for(int i = (l - 1) % 9 + 1; i <= 9; i++) ans += i;
l += 9 - (l - 1) % 9;
for(int i = (r - 1) % 9 + 1; i >= 1; i--) ans += i;
r -= (r - 1) % 9 + 1;
ans += ((r - l + 1) / 9) * 45;
cout << ans << endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |