Submission #976315

# Submission time Handle Problem Language Result Execution time Memory
976315 2024-05-06T12:22:11 Z vjudge1 Trol (COCI19_trol) C++17
50 / 50
1 ms 348 KB
#include <bits/stdc++.h>
#define bismillah ios_base::sync_with_stdio(0); cin.tie(0);
#define int 		  long long
#define v 			  vector
#define pb 			  push_back
#define ppb 		  pop_back
#define all(x)    x.begin(), x.end()
#define rall(x)   x.begin(), x.end()
#define pii 		  pair<int, int>
#define pll 		  pair<long long, long long>
#define fi 			  first
#define se 			  second
#define mp 			  make_pair
#define lb 			  lower_bound
#define ub 			  upper_bound
#define endl 		  '\n'
#define tc 			  int t = 1; while (t--)
// #define tc 			  int t; cin >> t; while (t--)
const int MOD = 1e9 + 7;
const int INF = 1e17;
using namespace std;

signed main(){
	bismillah;
	tc {
		//input
		int q; cin >> q;
		
		//solve
		while (q--) {
			int l, r;
			cin >> l >> r; l--;

			int ansLeft  = (l / 9) * 45;;
			int resLeft  = l % 9;
			for (int i   = 1; i <= resLeft; i++) {
				ansLeft += i;
			}
			int ansRight = (r / 9) * 45;;
			int resRight = r % 9;
			for (int i   = 1; i <= resRight; i++) {
				ansRight += i;
			}
			cout << ansRight - ansLeft << endl;
		} 
	}
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct