public class Solution {
public int MySqrt(int x) {
if(x < 2){
return x;
}
if(x > int.MaxValue){
x = int.MaxValue;
}
var half = 46340; // Sqrt(int.MaxValue)
for(var i = half; i >= 1; i--){
if(i * i == x){
return i;
}
if(i * i < x){
return i;
}
}
return -1;
}
}LeetCode-- Implement int sqrt(int x)
原文:http://blog.csdn.net/lan_liang/article/details/50144615