633. Sum of Square Numbers
2018-01-10 12:11
232 查看
bool judgeSquareSum(int c) { int b; for(int i=0;i<=sqrt(c);++i){ b=sqrt(c-i*i); if(i*i+b*b==c) return true; } return false; }
效率更高的代码
bool judgeSquareSum(int c) { int a=0,b=sqrt(c); while(a<=b){ if(a*a+b*b==c) return true; if(a*a+b*b<c) a++; else b--; } return false; }
相关文章推荐
- 2017.12.25 LeetCode 633. Sum of Square Numbers【思维枚举】
- LeetCode 633. Sum of Square Numbers
- LeetCode-633. Sum of Square Numbers
- [LeetCode]633. Sum of Square Numbers
- LeetCode.50(69\367\633) Pow(x,n)&&Sqrt(x)&&Valid Perfect Square&&Sum of Square Numbers
- Sum of Square Numbers问题描述
- LeetCode 633 Sum of Square Numbers
- bzoj 2986: Non-Squarefree Numbers【容斥+莫比乌斯函数】
- leetcode[Sum of Square Numbers]
- Math-633-Sum of Square Numbers
- LeetCode Sum of Square Numbers
- BZOJ2986 Non-Squarefree Numbers
- bzoj2986 Non-Squarefree Numbers (莫比乌斯函数)
- LeetCode 633 : Sum of Square Numbers(python)
- bzoj 2986: Non-Squarefree Numbers
- [BZOJ2986]Non-Squarefree Numbers(二分+容斥原理)
- 【LeetCode】Sum of Square Numbers 解题报告
- 2986: Non-Squarefree Numbers
- BZOJ2986 Non-Squarefree Numbers
- Sum of Square Numbers