제출 #259161

#제출 시각아이디문제언어결과실행 시간메모리
259161lani1akeaTrol (COCI19_trol)C++17
10 / 50
1076 ms384 KiB
#include <bits/stdc++.h>

#define F first
#define S second
#define int long long
#define pb push_back
#define endl '\n'
#define rep(x) cout << #x << "= " << x << endl
#define OK cout << "OK\n"
using namespace std;

const int MOD = 1e9 + 7;
const int N = 510;

int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int T;
	cin >> T;
	while(T--) {
		int a, b;
		cin >> a >> b;
		int ans = 0;
		if ( a + (9 - a % 9) + 1 <= b) {
			ans += 45 - (9 - a % 9) * (10 - a % 9) / 2;
			a += (9 - a % 9) + 1;
		}
		for (int i = a + 9; i <= b; i += 9) {
			ans += 45;
			a = i;
		}
		for (int i = a; i <= b; ++i)
			ans += (i % 9 ? i % 9 : 9) ;

		cout << ans << endl;
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...