// #include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll L, R;
int q;
ll f_(ll a)
{
if (a == 0)
return 0;
return a % 10 + f_(a / 10);
}
ll f(ll a)
{
ll hold = f_(a);
if (hold > 9)
return f(hold);
return hold;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> q;
while (q--)
{
cin >> L >> R;
ll sum = 0;
for (int i = L; i <= R; i++)
{
sum += f(i);
}
cout << sum << endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |