1 static int wing=[]()
 2 {
 3     std::ios::sync_with_stdio(false);
 4     cin.tie(NULL);
 5     return 0;
 6 }();
 7 
 8 class Solution 
 9 {
10 public:
11     bool isUgly(int num) 
12     {
13         if(num<1)
14             return false;
15         while(num%2==0) num/=2;
16         while(num%3==0) num/=3;
17         while(num%5==0) num/=5;
18         return num==1;
19     }
20 };

判定一个数中的因子是否只有235,将所有235分解出来就行,看最终结果是否为1.

posted on 2018-05-25 10:56  高数考了59  阅读(101)  评论(0)    收藏  举报