Submission #229215

#TimeUsernameProblemLanguageResultExecution timeMemory
229215VEGAnnTrol (COCI19_trol)C++14
50 / 50
6 ms256 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll ans(ll x){
	ll res = x / 9ll * (45ll);
	ll ost = x % 9;
	for (ll i = 1; i <= ost; i++)
		res += i;
	return res;
}

int main(){
	int qq; cin >> qq;
	
	for (; qq; qq--){
		ll l, r;
		cin >> l >> r;
		cout << ans(r) - ans(l - 1) << '\n';
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...