class Solution {
public:
bool isUgly(int n) {
if(n<=0)
{
return false;
}
vector<int>factors={2,3,5};
for(int factor:factors)
{
while(n % factor==0)
{
n /= factor;
}
}
return n==1;
}
};
263 丑数
最新推荐文章于 2024-11-02 20:41:42 发布