static auto x = []() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
return 0;
}();
class Solution {
public:
bool isUgly(int num) {
if(num < 1)
return false;
while(1){
if(num % 2 != 0)
break;
else
num = num/2;
}
while(1){
if(num % 3 != 0)
break;
else
num = num/3;
}
while(1){
if(num % 5 != 0)
break;
else
num = num/5;
}
if(num == 1)
return true;
else
return false;
}
};
效率:
100%