#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int q;
cin >> q;
while(q--)
{
int l, r;
cin >> l >> r;
int sum = 0;
sum += 45 * (r / 9);
while(r % 9 != 0)
{
sum += r % 9;
r--;
}
l--;
sum -= 45 * (l / 9);
while(l % 9 != 0)
{
sum -= l % 9;
l--;
}
cout << sum << "\n";
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |