結果

問題 No.1179 Quadratic Equation
ユーザー ks2mks2m
提出日時 2020-08-21 21:57:17
言語 Java21
(openjdk 21)
結果
AC  
実行時間 153 ms / 2,000 ms
コード長 527 bytes
コンパイル時間 2,283 ms
コンパイル使用メモリ 76,572 KB
実行使用メモリ 55,244 KB
最終ジャッジ日時 2024-04-23 05:51:27
合計ジャッジ時間 4,479 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 107 ms
53,704 KB
testcase_01 AC 128 ms
55,088 KB
testcase_02 AC 111 ms
54,420 KB
testcase_03 AC 111 ms
54,128 KB
testcase_04 AC 108 ms
54,192 KB
testcase_05 AC 145 ms
55,244 KB
testcase_06 AC 143 ms
54,784 KB
testcase_07 AC 149 ms
54,996 KB
testcase_08 AC 140 ms
55,112 KB
testcase_09 AC 137 ms
54,864 KB
testcase_10 AC 127 ms
54,788 KB
testcase_11 AC 118 ms
54,168 KB
testcase_12 AC 127 ms
55,032 KB
testcase_13 AC 153 ms
55,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		sc.close();

		int d = b * b - 4 * a * c;
		if (d < 0) {
			System.out.println("imaginary");
		} else if (d == 0) {
			System.out.println(-b / 2.0 / a);
		} else {
			double d2 = Math.sqrt(d);
			d2 = Math.abs(d2 / 2 / a);
			double e = -b / 2.0 / a;
			System.out.println(e - d2 + " " + (e + d2));
		}
	}
}
0