#include <bits/stdc++.h>
using namespace std;
int bil (int n){
while(n>=10){
int hasil=0;
while (n>0){
hasil+= n%10;
n/=10;
}
n= hasil;
}
return n;
}
int main(){
int q;
cin >> q;
for (int i=0; i<q; i++){
long long l, r;
long long sum=0;
cin >> l >> r;
for (int j=l; j<=r; j++){
sum+= bil(j);
}
cout << sum << endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
4 |
Execution timed out |
1087 ms |
404 KB |
Time limit exceeded |
5 |
Execution timed out |
1055 ms |
348 KB |
Time limit exceeded |