답안 #975558

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
975558 2024-05-05T13:23:06 Z vjudge1 Trol (COCI19_trol) C++17
50 / 50
1 ms 392 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;

bool bad[105] = {};
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int Q;
	ll L, R;
	cin >> Q;
	while (Q--) {
		cin >> L >> R;
		ll ans = (R/9) * 45 + ((R%9) * (R%9 + 1)) / 2;
		if (L > 1) {
			L--;
			ans -= (L/9) * 45 + ((L%9) * (L%9 + 1)) / 2;
		}
		cout << ans << '\n';
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 392 KB Output is correct
5 Correct 0 ms 344 KB Output is correct