# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
251447 |
2020-07-21T09:44:55 Z |
terencehill |
Trol (COCI19_trol) |
C++14 |
|
1 ms |
256 KB |
#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 |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
1 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |