#include <bits/stdc++.h>
using namespace std;
#define in long long
int bil (int n){
while(n>=10){
int hasil=0;
while (n>0){
hasil+= n%10;
n/=10;
}
n= hasil;
}
return n;
}
int main(){
in q;
cin >> q;
for (int i=0; i<q; i++){
in l, r;
in 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 |
600 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 |
1046 ms |
600 KB |
Time limit exceeded |
5 |
Execution timed out |
1058 ms |
348 KB |
Time limit exceeded |