#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;
}
# |
결과 |
실행 시간 |
메모리 |
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 |