lina_os

Untitled

Apr 2nd, 2025
12
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  8. int t;
  9. cin >> t;
  10. while (t--) {
  11. string x,y;
  12. cin >> x >> y;
  13. ll ans=0;
  14. ll i=x.size()+1;
  15. while (i<y.size()) {
  16. if (i%2==1) {
  17. ans+=(ll)pow(10,i-1)*9;
  18. }
  19. i++;
  20. }
  21. if (x.size()%2==1) {
  22. string s(x.size(), '9');
  23. ans+= min(stoi(y),stoi(s))-stoi(x)+1;
  24. }
  25. if (y.size()%2==1&&y.size()!=x.size()) {
  26. string s(y.size()-1, '9');
  27. ans+= stoi(y)-stoi(s);
  28. }
  29. cout << ans << endl;
  30. }
  31. return 0;
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment