結果

問題 No.955 ax^2+bx+c=0
ユーザー ks2mks2m
提出日時 2019-12-18 00:47:54
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,802 bytes
コンパイル時間 2,623 ms
コンパイル使用メモリ 75,732 KB
実行使用メモリ 52,292 KB
最終ジャッジ日時 2023-09-21 05:30:52
合計ジャッジ時間 11,799 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
50,396 KB
testcase_01 AC 43 ms
49,208 KB
testcase_02 AC 42 ms
47,528 KB
testcase_03 AC 42 ms
49,344 KB
testcase_04 AC 43 ms
49,612 KB
testcase_05 AC 42 ms
49,424 KB
testcase_06 AC 42 ms
49,504 KB
testcase_07 AC 42 ms
49,204 KB
testcase_08 AC 43 ms
49,176 KB
testcase_09 AC 43 ms
49,468 KB
testcase_10 AC 42 ms
49,452 KB
testcase_11 AC 41 ms
49,336 KB
testcase_12 AC 42 ms
49,640 KB
testcase_13 AC 41 ms
49,568 KB
testcase_14 AC 43 ms
49,192 KB
testcase_15 AC 43 ms
49,376 KB
testcase_16 AC 43 ms
49,684 KB
testcase_17 AC 43 ms
49,416 KB
testcase_18 AC 43 ms
49,172 KB
testcase_19 AC 42 ms
49,384 KB
testcase_20 AC 42 ms
49,496 KB
testcase_21 AC 43 ms
49,136 KB
testcase_22 AC 43 ms
49,476 KB
testcase_23 AC 44 ms
47,460 KB
testcase_24 AC 42 ms
49,216 KB
testcase_25 AC 43 ms
49,192 KB
testcase_26 AC 43 ms
49,504 KB
testcase_27 AC 42 ms
49,180 KB
testcase_28 AC 43 ms
49,204 KB
testcase_29 AC 43 ms
49,792 KB
testcase_30 AC 43 ms
49,328 KB
testcase_31 AC 43 ms
49,656 KB
testcase_32 AC 42 ms
49,332 KB
testcase_33 AC 43 ms
49,320 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 62 ms
50,920 KB
testcase_38 AC 55 ms
50,468 KB
testcase_39 AC 55 ms
50,532 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 63 ms
50,724 KB
testcase_44 AC 56 ms
50,344 KB
testcase_45 AC 56 ms
50,260 KB
testcase_46 AC 60 ms
50,916 KB
testcase_47 AC 56 ms
50,384 KB
testcase_48 AC 54 ms
50,692 KB
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 AC 60 ms
50,464 KB
testcase_53 AC 55 ms
50,232 KB
testcase_54 AC 55 ms
50,392 KB
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 RE -
testcase_59 RE -
testcase_60 AC 42 ms
49,180 KB
testcase_61 AC 43 ms
49,204 KB
testcase_62 RE -
testcase_63 RE -
testcase_64 AC 43 ms
49,276 KB
testcase_65 RE -
testcase_66 AC 42 ms
49,484 KB
testcase_67 RE -
testcase_68 AC 43 ms
49,540 KB
testcase_69 RE -
testcase_70 RE -
testcase_71 AC 42 ms
49,284 KB
testcase_72 AC 42 ms
49,396 KB
testcase_73 RE -
testcase_74 RE -
testcase_75 AC 42 ms
49,580 KB
testcase_76 AC 44 ms
49,668 KB
testcase_77 RE -
testcase_78 RE -
testcase_79 RE -
testcase_80 AC 43 ms
49,660 KB
testcase_81 RE -
testcase_82 AC 42 ms
49,332 KB
testcase_83 AC 43 ms
49,600 KB
testcase_84 AC 42 ms
47,596 KB
testcase_85 AC 42 ms
49,292 KB
testcase_86 AC 43 ms
49,176 KB
testcase_87 AC 42 ms
49,264 KB
testcase_88 AC 42 ms
49,332 KB
testcase_89 AC 43 ms
49,508 KB
testcase_90 AC 44 ms
49,480 KB
testcase_91 AC 43 ms
49,364 KB
testcase_92 AC 42 ms
49,524 KB
testcase_93 AC 43 ms
49,304 KB
testcase_94 AC 42 ms
47,384 KB
testcase_95 AC 43 ms
47,376 KB
testcase_96 AC 43 ms
49,412 KB
testcase_97 AC 43 ms
49,764 KB
testcase_98 AC 43 ms
49,408 KB
testcase_99 AC 42 ms
49,476 KB
testcase_100 AC 42 ms
49,348 KB
testcase_101 AC 42 ms
49,460 KB
testcase_102 AC 43 ms
49,500 KB
testcase_103 AC 42 ms
49,428 KB
testcase_104 AC 43 ms
49,588 KB
testcase_105 AC 43 ms
49,336 KB
testcase_106 AC 42 ms
49,360 KB
testcase_107 AC 42 ms
49,604 KB
testcase_108 AC 42 ms
49,284 KB
testcase_109 AC 42 ms
49,492 KB
testcase_110 AC 43 ms
49,276 KB
testcase_111 AC 43 ms
49,288 KB
testcase_112 AC 43 ms
49,784 KB
testcase_113 AC 43 ms
49,364 KB
testcase_114 AC 43 ms
49,368 KB
testcase_115 AC 43 ms
49,568 KB
testcase_116 AC 42 ms
49,556 KB
testcase_117 AC 43 ms
49,584 KB
testcase_118 AC 42 ms
49,372 KB
testcase_119 AC 42 ms
49,536 KB
testcase_120 AC 42 ms
49,368 KB
testcase_121 AC 42 ms
49,212 KB
testcase_122 AC 55 ms
50,572 KB
testcase_123 AC 53 ms
50,348 KB
testcase_124 AC 55 ms
50,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		long a = Integer.parseInt(sa[0]);
		long b = Integer.parseInt(sa[1]);
		long c = Integer.parseInt(sa[2]);
		br.close();

		if (a == 0) {
			if (b == 0) {
				if (c == 0) {
					System.out.println(-1);
				} else {
					System.out.println(0);
				}
			} else {
				System.out.println(1);
				System.out.println((double) -c / b);
			}
		} else if (b * b == 4 * a * c) {
			System.out.println(1);
			System.out.println((double) -b / 2 / a);
		} else if (b * b > 4 * a * c) {
			long d = b * b - 4 * a * c;
			BigDecimal bd = BigDecimal.valueOf(d);
			BigDecimal sq = BigDecimal.valueOf((long) Math.sqrt(d));
			StringBuilder sb = new StringBuilder("0.");
			for (int i = 0; i < 20; i++) {
				for (int j = 0; j < 10; j++) {
					BigDecimal v = new BigDecimal(sb.toString() + "1");
					BigDecimal tmp = sq.add(v);
					tmp = tmp.multiply(tmp);
					if (tmp.compareTo(bd) > 0) {
						break;
					}
					sq = sq.add(v);
				}
				sb.append("0");
			}
			System.out.println(2);
			BigDecimal ba = BigDecimal.valueOf(a);
			BigDecimal two = BigDecimal.valueOf(2);
			BigDecimal mb = BigDecimal.valueOf(b).negate();
			BigDecimal ans1 = mb.subtract(sq).divide(two).divide(ba);
			BigDecimal ans2 = mb.add(sq).divide(two).divide(ba);
			if (ans1.compareTo(ans2) < 0) {
				System.out.println(ans1.toPlainString());
				System.out.println(ans2.toPlainString());
			} else {
				System.out.println(ans2.toPlainString());
				System.out.println(ans1.toPlainString());
			}
		} else {
			System.out.println(0);
		}
	}
}
0