Submission #238740

# Submission time Handle Problem Language Result Execution time Memory
238740 2020-06-12T14:04:24 Z Halit Trol (COCI19_trol) C++17
10 / 50
6 ms 384 KB
#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
1 Correct 5 ms 256 KB Output is correct
2 Incorrect 5 ms 256 KB Output isn't correct
3 Incorrect 5 ms 256 KB Output isn't correct
4 Incorrect 6 ms 256 KB Output isn't correct
5 Incorrect 5 ms 384 KB Output isn't correct