Submission #221128

# Submission time Handle Problem Language Result Execution time Memory
221128 2020-04-09T15:01:04 Z eohomegrownapps Trol (COCI19_trol) C++14
50 / 50
5 ms 384 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

vector<ll> pref;

ll suminc(ll x){
	if (x==0){
		return 0;
	}
	return pref[9]*(x/9)+pref[(x%9)];
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	int q;
	cin>>q;
	pref.resize(10,0);
	for (int i = 1; i<=9; i++){
		pref[i]=pref[i-1]+i;
	}
	for (int i = 0; i<q; i++){
		ll l,r;
		cin>>l>>r;
		cout<<(suminc(r)-suminc(l-1))<<'\n';
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct