Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
- using namespace std;
- int main()
- {
- fastio;
- int t;
- cin >> t;
- while(t--)
- {
- int a,b;
- cin >> a >> b;
- int i;
- int answer = 0;
- for(i = a; i <= b;i++)
- {
- int x = i;
- int digit_count[10] = {0};//initialize this array to zero
- while(x != 0)
- {
- int current_digit = x % 10;
- if(digit_count[current_digit] == 1)
- {
- answer++;//one digit has repeated, so this number is part of the count.
- break;
- }
- digit_count[current_digit]++;
- x = x / 10;//get the next digit
- }
- }
- cout << answer << '\n';
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment