private static int core(int n){ int small=0,big=n/2+1,mid=0; while(small<big){ mid = small+(big-small)/2; if(mid*mid>n) big = mid-1; else if(mid*mid<n) small=mid+1; else return mid; } int s=0,e=0; if(mid*mid>n){ s = mid-1;e = mid; }else{ s = mid;e = mid+1; } double m = (s+e)/2.0; if(m*m<n) return e; else return s; }