Untitled
unknown
c_cpp
a year ago
898 B
11
Indexable
Never
#include <iostream> #include <vector> using namespace std; // Function to check if a number is a Champ Number bool isChampNumber(long long num) { bool digits[6] = {false}; // digits array to check uniqueness while (num) { int digit = num % 10; // If digit is greater than 5 or already occurred, return false if (digit > 5 || digits[digit]) { return false; } digits[digit] = true; num /= 10; } return true; } int main() { int Q; cin >> Q; for (int q = 0; q < Q; ++q) { long long X, Y; cin >> X >> Y; int count = 0; for (long long i = X; i <= Y; ++i) { if (isChampNumber(i)) { count++; } } cout << count << endl; } return 0; }