Submission #977050

# Submission time Handle Problem Language Result Execution time Memory
977050 2024-05-07T10:48:23 Z vjudge1 Trol (COCI19_trol) C++17
50 / 50
1 ms 348 KB
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define fi first
#define se second
#define pb push_back
#define pll pair<long long, long long>
#define loop(i,n) for(int i=1;i<=n;i++)
#define loop0(i,n) for(int i=0;i<n;i++)
using namespace std;

//pbds template
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;

//template <class T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

ll calc(ll a){
	ll ans = a/9 * 45;
	for(int i=1;i<=(a%9);i++){
		ans += i;
	}
	return ans;
}

void solve(){
	int tc;
	cin >> tc;
	for(int q=1;q<=tc;q++){
		ll l,r;
		cin >> l >> r;
		cout << calc(r)-calc(l-1) << endl;
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tc = 1;
//	cin >> tc;
	while(tc--){
	   solve();
	}
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 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 0 ms 348 KB Output is correct