# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1259851 | khaerulmamu | Trol (COCI19_trol) | C++20 | 0 ms | 328 KiB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main (){
int Q;
cin >> Q;
while (Q--){
ll l ,r;
cin >> l >> r;
ll dif = r-l+1;
int a;
if(l%9==0)a=9;
else a= l%9;
ll ans=0;
while(a<=9 && dif>0){
ans+=a;
a++;
dif--;
}
if(dif/9 > 0){
ans+=45*(dif/9);
}
int tambahan = dif - 9*(dif/9);
for(int i=1; i<=tambahan; i++){
ans +=i;
}
cout << ans << endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |