Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ll long long
- using namespace std;
- int main() {
- ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
- int t;
- cin >> t;
- while (t--) {
- string x,y;
- cin >> x >> y;
- ll ans=0;
- ll i=x.size()+1;
- while (i<y.size()) {
- if (i%2==1) {
- ans+=(ll)pow(10,i-1)*9;
- }
- i++;
- }
- if (x.size()%2==1) {
- string s(x.size(), '9');
- ans+= min(stoi(y),stoi(s))-stoi(x)+1;
- }
- if (y.size()%2==1&&y.size()!=x.size()) {
- string s(y.size()-1, '9');
- ans+= stoi(y)-stoi(s);
- }
- cout << ans << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment