#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll sudigi(ll x, ll ret){
if(x < 10){
ret += x;
return ret;
}
return sudigi(x/10, (x%10) + ret);
}
int main(){
ll q; cin >> q;
while(q--){
ll ans = 0;
ll a, b; cin >> a >> b;
for(ll i = a; i <= b; i++){
ll total = i;
while(total > 9){
total = sudigi(total, 0);
}
ans += total;
}
cout << ans << endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Execution timed out |
1060 ms |
404 KB |
Time limit exceeded |
5 |
Execution timed out |
1044 ms |
348 KB |
Time limit exceeded |