题目链接
728. 自除数
数据范围小,暴力枚举就可以。
class Solution {
public:
bool check(int x){
int n = x;
while(n){
int t = n % 10;
if(t == 0 || x % t != 0) return false;
n /= 10;
}
return true;
}
vector<int> selfDividingNumbers(int left, int right) {
vector<int> res;
for(int i = left; i <= right; i++)
if(check(i)) res.push_back(i);
return res;
}
};