Guest User

Brute force Code for ARJN

a guest
Jun 18th, 2019
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
  3. using namespace std;
  4. int main()
  5. {
  6.     fastio;
  7.     int t;
  8.     cin >> t;
  9.     while(t--)
  10.     {
  11.         int a,b;
  12.         cin >> a >> b;
  13.         int i;
  14.         int answer = 0;
  15.         for(i = a; i <= b;i++)
  16.         {
  17.             int x = i;
  18.             int digit_count[10] = {0};//initialize this array to zero
  19.             while(x != 0)
  20.             {
  21.                 int current_digit = x % 10;
  22.                 if(digit_count[current_digit] == 1)
  23.                 {
  24.                     answer++;//one digit has repeated, so this number is part of the count.
  25.                     break;
  26.                 }
  27.                 digit_count[current_digit]++;
  28.                 x = x / 10;//get the next digit
  29.             }
  30.         }
  31.         cout << answer << '\n';
  32.     }
  33.     return 0;
  34. }
Add Comment
Please, Sign In to add comment