第3题: Scanner in = new Scanner(System.in); int total = Integer.parseInt(in.nextLine()); for (int i = 0; i < total; i++) { String[] xy = in.nextLine().split(" "); long x = Long.parseLong(xy[0]); long y = Long.parseLong(xy[1]); long dist = Math.abs(x - y); if (dist == 0) { System.out.println(0); continue; } long n = 0; while (n * n <= dist) { n++; } n--; long left = dist - n * n; long add1 = left / n; long add2 = left % n; long ans = 2 * n - 1 + add1; if (add2 != 0){ ans += 1; } System.out.println(ans); }