367ValidPerfectSquare
来源:互联网 发布:淘宝店铺年度运营计划 编辑:程序博客网 时间:2024/06/05 22:05
题意:输入一个数,判断该数是否是完全平方数(true是,false否),要求不能使用库函数sqrt
思路:1、任何一个数都能质因数分解,判断质因子是否成对出现;(超时)O(sqrt(n))
2、找到a^2 = n中a的值,采用binary search。O(log(n/2))
3 、递推关系式, x^2 - (x-1)^2 = 2x-1 ,... 3^2 - 2^2 = 2*3 -1, 2^2-1^2 = 2*2 -1, 所以,x^2 = 1+3+5+...+ (2x-1),即如果一个数是完全平方数,必定能写成1、3。。。的序列
0 0
- 367ValidPerfectSquare
- ocp-367
- nyoj 367 Reward
- codeforces 367C
- sgu 499 367页
- codeforces round 367
- 367_EditText禁止换行
- Codeforces 367E
- Codeforces 367A
- Codeforces 367B
- codeforces 367B
- LeetCode 367 Valid Perfect Square
- leetcode 367 Valid Perfect Square
- LeetCode[367] Valid Perfect Square
- Codeforces Round #367 (Div. 2)
- Codeforces Round #367 (Div. 2)
- Codeforces Round #367 (Div. 2)
- Codeforces Round #367 (Div. 2)
- 队列和栈
- java程序员最常用的8个日志框架
- 该如何让自己从一个c++程序员变成一个delphi程序员
- LeetCode 8. String to Integer (atoi)简单易懂的解法
- MTK FileManager无法分享视频到Youtube应用
- 367ValidPerfectSquare
- struts2 中文乱码问题
- asp.net spring.net+mvc 和j2ee spring mvc的思考
- WebView下拉刷新Demo
- -fpic -fPIC -fpie -fPIE
- NSEnumerator用法及找到添加到view中最上层的subview
- 使用Spring Cloud Zuul实现动态路由
- MySQL 索引介绍 属性介绍 注意事项
- java调色板的代码