답안 #871601

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
871601 2023-11-11T07:21:41 Z vjudge1 Trol (COCI19_trol) C++11
50 / 50
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){

	int q;
	cin >> q;
	while(q--) {
		ll a, b;
		cin >> a >> b ;

		a--;

		ll temp1 = (a-1)/9;
		ll tm = temp1 * 45;
		temp1 = max(0ll, (((a-9*temp1)) * ((a-9*temp1)+1)) / 2);
		temp1 += tm;

		
		ll temp2 = (b-1)/9;
		ll tm2 = temp2 * 45;
		
		temp2 = max(0ll, (((b-9*temp2)) * ((b-9*temp2)+1)) / 2);

		temp2 += tm2;
		
		cout << temp2 - temp1 << "\n";
		
	}

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct