首页 > 其他 > 详细

367. Valid Perfect Square

时间:2018-05-26 16:19:53      阅读:182      评论:0      收藏:0      [点我收藏+]

n*n=1+2+3+...+(2n-1)

 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 isPerfectSquare(int num) 
12     {
13         for(int i=1;num>0;i+=2)
14             num-=i;
15         return num==0;
16     }
17 };

 

367. Valid Perfect Square

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

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