結果

問題 No.1179 Quadratic Equation
ユーザー tentententen
提出日時 2020-08-24 22:14:52
言語 Java21
(openjdk 21)
結果
AC  
実行時間 167 ms / 2,000 ms
コード長 573 bytes
コンパイル時間 2,277 ms
コンパイル使用メモリ 76,356 KB
実行使用メモリ 42,588 KB
最終ジャッジ日時 2024-04-24 03:56:23
合計ジャッジ時間 5,126 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
41,136 KB
testcase_01 AC 164 ms
42,388 KB
testcase_02 AC 118 ms
39,828 KB
testcase_03 AC 118 ms
40,180 KB
testcase_04 AC 131 ms
41,500 KB
testcase_05 AC 147 ms
42,380 KB
testcase_06 AC 163 ms
42,488 KB
testcase_07 AC 162 ms
42,404 KB
testcase_08 AC 164 ms
42,536 KB
testcase_09 AC 164 ms
42,380 KB
testcase_10 AC 160 ms
42,500 KB
testcase_11 AC 129 ms
41,276 KB
testcase_12 AC 151 ms
42,152 KB
testcase_13 AC 167 ms
42,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
    	double a = sc.nextInt();
    	double b = sc.nextInt();
    	double c = sc.nextInt();
    	double d = b * b - 4 * a * c;
    	if (d < 0) {
    	    System.out.println("imaginary");
    	} else if (d == 0) {
    	    System.out.println(-b / 2/ a);
    	} else {
    	    double x = (-b - Math.sqrt(d)) / 2 / a;
    	    double y = (-b + Math.sqrt(d)) / 2 / a;
    	    System.out.println(Math.min(x, y) + " " + Math.max(x, y));
    	}
    }
}

0