結果

問題 No.172 UFOを捕まえろ
ユーザー takeya_okinotakeya_okino
提出日時 2017-06-23 16:43:02
言語 Java21
(openjdk 21)
結果
AC  
実行時間 137 ms / 5,000 ms
コード長 602 bytes
コンパイル時間 2,165 ms
コンパイル使用メモリ 74,672 KB
実行使用メモリ 54,320 KB
最終ジャッジ日時 2024-04-14 06:57:21
合計ジャッジ時間 6,522 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
53,880 KB
testcase_01 AC 132 ms
53,980 KB
testcase_02 AC 132 ms
54,052 KB
testcase_03 AC 134 ms
54,288 KB
testcase_04 AC 133 ms
54,216 KB
testcase_05 AC 133 ms
53,856 KB
testcase_06 AC 133 ms
54,176 KB
testcase_07 AC 134 ms
54,216 KB
testcase_08 AC 136 ms
54,120 KB
testcase_09 AC 134 ms
54,240 KB
testcase_10 AC 133 ms
54,104 KB
testcase_11 AC 133 ms
54,240 KB
testcase_12 AC 135 ms
53,964 KB
testcase_13 AC 137 ms
54,088 KB
testcase_14 AC 134 ms
53,992 KB
testcase_15 AC 134 ms
54,040 KB
testcase_16 AC 134 ms
54,320 KB
testcase_17 AC 134 ms
54,196 KB
testcase_18 AC 133 ms
53,952 KB
testcase_19 AC 133 ms
54,192 KB
testcase_20 AC 132 ms
54,212 KB
testcase_21 AC 137 ms
54,248 KB
testcase_22 AC 137 ms
54,116 KB
testcase_23 AC 135 ms
54,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    int r = sc.nextInt();
    int a = 0;
    for(int i = 1; i <= 200; i++) {
      if(i * i > 2 * r * r) {
        a = i;
        break;
      }
    }
    int s = Math.abs(Math.min(0, x - a - y));
    int t = Math.abs(Math.min(0, x - a + y));
    int u = Math.abs(Math.max(0, x + a + y));
    int v = Math.abs(Math.max(0, x + a - y));
    int ans = Math.max(Math.max(s, t), Math.max(u, v));
    System.out.println(ans);
  }
}
0