#include<iostream>
using namespace std;
#define int long long
#ifdef lioraju
#define ndbg(x)
#else
#define ndbg(x) x
#endif
int f(int i)
{
if (i<10) return i;
int sum = 0;
while (i)
sum += i%10, i/=10;
return f(sum);
}
signed main()
{
ndbg( ios::sync_with_stdio(0); cin.tie(0); );
int q; cin>>q;
for (int qi=0; qi<q; qi++)
{
int l, r, sum = 0; cin>>l>>r;
for (int i=l;i<=r;i++)
sum += f(i);
cout<<sum<<'\n';
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
6 ms |
376 KB |
Output is correct |
3 |
Correct |
7 ms |
376 KB |
Output is correct |
4 |
Execution timed out |
1067 ms |
376 KB |
Time limit exceeded |
5 |
Execution timed out |
1089 ms |
376 KB |
Time limit exceeded |