| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 238740 | Halit | Trol (COCI19_trol) | C++17 | 6 ms | 384 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const bool cannot = 0;
int main(){
	int q;
	cin >> q;
	while(q--){
		long long l,r, templ, tempr, reml, remr, nons, ans = 0, rans, lans;
		cin >> l >> r;
		reml = l % 9;
		remr = r % 9;
		if(l <= 9 && r <= 9){
			for(int i = l;i <= r;i++)
				ans += i;
			cout << ans << "\n";
			continue;
		}
		else if(l <= 9){
			lans = 45 - (l) * (l-1) / 2;
			goto NEXT;
		}
		
		templ = (10 - ((reml == 0) * 9 + reml)) + l;
		tempr = r - ((remr == 0) * 9 + remr - 1);
		
		lans = 45 - (9 - (10 - ((reml == 0) * 9 + reml))) * (10 - (10 - ((reml == 0) * 9 + reml))) / 2;
		
		nons = (tempr - templ + 1) / 9 * 45;
		rans = (remr * remr + remr) / 2 - 1;
		if(cannot){
			NEXT : ;
			tempr = r - ((remr == 0) * 9 + remr - 1);
			nons = (tempr) / 9 - 1;
			rans = (remr * remr + remr) / 2 - 1;
		}
		ans = nons + rans + lans + 1;
		cout << ans << "\n";
	}
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
