0357.cpp (258B)
1 class Solution { 2 public: 3 int countNumbersWithUniqueDigits(const int n) const { 4 if (n == 0) return 1; 5 6 int res = 10, acc = 9, crnt = 9; 7 for (int i = 2; i <= n; i++) 8 res += acc *= crnt--; 9 10 return res; 11 } 12 };