#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int q;
cin >> q;
while (q--)
{
int l, r;
cin >> l >> r;
int start = l % 9;
if (start == 0)
start = 9;
int end = r - l + start;
ll ans = 0;
for (int i = start; i <= end; i++)
{
int cur = i % 9;
if (cur == 0)
{
cur = 9;
}
ans += cur;
}
cout << ans << endl;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Incorrect |
1 ms |
600 KB |
Output isn't correct |
4 |
Execution timed out |
1094 ms |
452 KB |
Time limit exceeded |
5 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |