# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
991227 | vjudge1 | Trol (COCI19_trol) | C++17 | 1090 ms | 604 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 f(int x){
while(x>9){
int cur = x;
int sum = 0;
while(cur!=0){
sum += cur%10;
cur/=10;
}
x = sum;
}
return x;
}
int g(int l, int r){
int ans = 0;
for(int i = l; l<=r; i++){
ans+=f(i);
}
return ans;
}
int main(){
int q;
cin >> q;
while(q--){
int l,r;
cin >> l >> r;
cout << g(l,r) << endl;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |