Submission #975619

# Submission time Handle Problem Language Result Execution time Memory
975619 2024-05-05T15:00:07 Z vjudge1 Trol (COCI19_trol) C++17
50 / 50
1 ms 348 KB
#include<bits/stdc++.h>
using namespace std;

using ll = unsigned long long;

signed main() {
	int q;
	cin >> q;

	while (q--) {
		ll l, r;
		cin >> l >> r;

		ll ans = 0;

		for (ll i = l; i <= min(r, l + 8LL); i++) {
			if (i % 9LL == 0) {
				ans += 9LL * ((r - i) / 9LL) + 9LL;
			} 
			else {
				ans += (i % 9LL) * ((r - i) / 9LL) + (i % 9LL);
			}
		}

		cout << ans << '\n';
	}
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct