# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
976287 | vjudge1 | Trol (COCI19_trol) | C++17 | 3 ms | 2140 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;
#define int long long
const int maxn=1e5;
int arr[maxn];
void buat1(int &n){
int sum=0;
while(n!=0){
sum= sum+ (n%10);
n/=10;
}
n=sum;
}
void pre_compute(){
for(int i=0; i<=maxn; i++){
int keepi=i;
while(keepi - 10 >= 0){
buat1(keepi);
}arr[i] = keepi;
}
}
signed main(){
memset(arr,0,sizeof(arr));
pre_compute();
int q;
cin >> q;
while(q--){
int l,r;
cin >> l>> r;
int sum=0;
for(int i=l; i<=r ;i++){
sum+=arr[i];
}
cout << sum<<"\n";
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |