#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define debug(x) cerr << #x << " --> " << x << endl;
#define shine ios_base::sync_with_stdio(false), cin.tie(nullptr);
const ll mod = 1e9 + 7;
const ll inf = 1e18;
int main(){
shine
ll q;
cin >> q;
while(q--){
ll l, r;
cin >> l >> r;
l--;
ll cnt1 = r / 9, cnt2 = l / 9, mod1 = r % 9, mod2 = l % 9;
ll ans = (cnt1 - cnt2 + ((mod1*(mod1+1)-(mod2*(mod2+1))) >> 1));
cout << ans << endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |