```
class Solution {
public:
int countNumbersWithUniqueDigits(int n) {
if(n > 10){
n = 10;
}
if(n == 0){
return 1;
}else if(n == 1){
return 10;
}
int num = 10;
for(int k = 2; k <= n; ++k){
int tmp = 9;
for(int i = 9; i >= 11 - k; --i){
tmp *= i;
}
num += tmp;
}
return num;
}
};
```