Submission #1252947

#TimeUsernameProblemLanguageResultExecution timeMemory
1252947mardaTrol (COCI19_trol)C++20
20 / 50
1 ms328 KiB
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <tuple>

#define endl "\n"
#define int long long int
#define ld long double
#define mp make_pair
#define pb push_back
#define Bound 1001

using namespace std;


int32_t main()
{

	int t;
	cin >> t;

	while (t--) {

		int64_t a, b;
		cin >> a >> b;


		int64_t firstNum = (a - 1) % 9 + 1;
		int64_t secondNum = (b - 1) % 9 + 1;
		int64_t difference = b - a + 1;

		int64_t totalTo9_1st = (10 - firstNum) * (9 + firstNum) / 2;
		int64_t totalTo9_2nd = (secondNum) * (1 + secondNum) / 2;

		int64_t dfrc = ceil((float)b / 9) - ceil((float)a / 9) - 1;

		cout << totalTo9_1st + totalTo9_2nd + dfrc * 45 << endl;

	}

	return 0;

}
#Verdict Execution timeMemoryGrader output
Fetching results...