답안 #229215

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
229215 2020-05-03T21:01:47 Z VEGAnn Trol (COCI19_trol) C++14
50 / 50
6 ms 256 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

ll ans(ll x){
	ll res = x / 9ll * (45ll);
	ll ost = x % 9;
	for (ll i = 1; i <= ost; i++)
		res += i;
	return res;
}

int main(){
	int qq; cin >> qq;
	
	for (; qq; qq--){
		ll l, r;
		cin >> l >> r;
		cout << ans(r) - ans(l - 1) << '\n';
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 6 ms 256 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct