import java.util.Scanner;
public class test14 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int x = sc.nextInt();
System.out.println(mySqrt(x));
}
public static int mySqrt(int x){
if (x == 0) {
return 0;
}
int ans = (int) Math.exp(0.5 * Math.log(x));
return (long) (ans + 1) * (ans + 1) <= x ? ans + 1 : ans;
}
}
leetcode014--实现开平方mySqrt()函数
最新推荐文章于 2023-09-02 18:47:36 发布