結果
問題 | No.2420 Simple Problem |
ユーザー | hiromi_ayase |
提出日時 | 2023-08-12 15:01:05 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,347 bytes |
コンパイル時間 | 3,056 ms |
コンパイル使用メモリ | 79,336 KB |
実行使用メモリ | 60,288 KB |
最終ジャッジ日時 | 2024-11-19 22:53:15 |
合計ジャッジ時間 | 21,591 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 52 ms
50,588 KB |
testcase_01 | AC | 388 ms
60,200 KB |
testcase_02 | AC | 90 ms
52,424 KB |
testcase_03 | AC | 251 ms
59,212 KB |
testcase_04 | AC | 487 ms
59,896 KB |
testcase_05 | AC | 410 ms
59,756 KB |
testcase_06 | AC | 533 ms
59,856 KB |
testcase_07 | AC | 528 ms
59,920 KB |
testcase_08 | AC | 540 ms
59,916 KB |
testcase_09 | AC | 526 ms
60,040 KB |
testcase_10 | AC | 533 ms
60,056 KB |
testcase_11 | AC | 522 ms
60,084 KB |
testcase_12 | AC | 524 ms
59,704 KB |
testcase_13 | AC | 525 ms
60,288 KB |
testcase_14 | AC | 534 ms
60,112 KB |
testcase_15 | AC | 526 ms
60,160 KB |
testcase_16 | AC | 549 ms
59,940 KB |
testcase_17 | AC | 521 ms
59,964 KB |
testcase_18 | AC | 531 ms
59,996 KB |
testcase_19 | AC | 552 ms
60,220 KB |
testcase_20 | AC | 548 ms
59,988 KB |
testcase_21 | AC | 524 ms
59,832 KB |
testcase_22 | AC | 533 ms
60,048 KB |
testcase_23 | AC | 528 ms
59,996 KB |
testcase_24 | AC | 543 ms
60,056 KB |
testcase_25 | AC | 523 ms
60,232 KB |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | AC | 52 ms
50,552 KB |
testcase_33 | AC | 395 ms
59,632 KB |
ソースコード
import java.util.*; import java.io.*; @SuppressWarnings("unused") public class Main { private static void solve() { int n = ni(); for (int i = 0; i < n; i ++) { solve(ni(), ni()); } } private static void solve(long a, long b) { // a + b + 2sqrt(ab) < x^2 // x^2 - a - b > 2sqrt(ab) // (x^2 - a- b)^2 > 4ab long ok = (int)Math.sqrt(1e9) * 2 + 100; long ng = 0; while (Math.abs(ok - ng) > 1) { long x = (ok + ng) / 2; double y = (x * x - a - b) - 2 * Math.sqrt(a * b); if (y > 0) { ok = x; } else { ng = x; } } out.println(ok); } public static void main(String[] args) { new Thread(null, new Runnable() { @Override public void run() { solve(); out.flush(); } }, "", 64000000).start(); } private static PrintWriter out = new PrintWriter(System.out); private static StringTokenizer tokenizer = null; private static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 32768); public static String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new java.util.StringTokenizer(reader.readLine()); } catch (Exception e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } private static double nd() { return Double.parseDouble(next()); } private static long nl() { return Long.parseLong(next()); } private static int[] na(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = ni(); return a; } private static char[] ns() { return next().toCharArray(); } private static long[] nal(int n) { long[] a = new long[n]; for (int i = 0; i < n; i++) a[i] = nl(); return a; } private static int[][] ntable(int n, int m) { int[][] table = new int[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { table[i][j] = ni(); } } return table; } private static int[][] nlist(int n, int m) { int[][] table = new int[m][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { table[j][i] = ni(); } } return table; } private static int ni() { return Integer.parseInt(next()); } }