# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1259724 | krisnandaaa | Trol (COCI19_trol) | C++20 | 0 ms | 328 KiB |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll pref(ll x){
if(x <= 0) return 0;
ll full = x / 9;
ll tmp = x % 9;
return 45LL * full + (tmp * (tmp + 1)) / 2;
}
ll simul(ll l, ll r){
return pref(r) - pref(l-1);
}
int main (){
ios::sync_with_stdio(0);
cin.tie(0);
int q; cin >> q;
while(q--){
ll l,r; cin >> l >> r;
cout << simul(l,r) << '\n';
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |