# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
971254 | vjudge1 | Trol (COCI19_trol) | C++98 | 1 ms | 348 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int sumDigits(long long num) {
long long sum = 0;
while (num > 0) {
sum += num % 10;
num /= 10;
}
if(sum>9){
return sumDigits(sum);
}else{
return sum;
}
}
int main(){
int q;
cin>>q;
while (q--)
{
long long l,r;
cin>>l>>r;
long long awal=sumDigits(l);
long long akhir=sumDigits(r);
long long yang_akan_dikurangi=(((r+(9-(r%9)))-(l-(l%9)))/9)*45;
cout<<yang_akan_dikurangi-(((awal-1)*(awal))/2)-((9-akhir)*(10+akhir)/2)<<endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |