首页 > 其他 > 详细

342. Power of Four

时间:2018-05-25 18:55:47      阅读:141      评论:0      收藏:0      [点我收藏+]
 1 static int wing=[]()
 2 {
 3     std::ios::sync_with_stdio(false);
 4     cin.tie(NULL);
 5     return 0;
 6 }();
 7 
 8 
 9 class Solution 
10 {
11 
12 public:
13     bool isPowerOfFour(int num) 
14     {
15         return ((num-1)&num)==0 && (num-1)%3==0;
16     }
17 
18 };

像这种本身就是某数的幂的,除了int最大幂求余为0外,还有加个判定,就是(num-1)%(n-1)==0

342. Power of Four

原文:https://www.cnblogs.com/zhuangbijingdeboke/p/9090085.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!