結果
問題 | No.955 ax^2+bx+c=0 |
ユーザー | ks2m |
提出日時 | 2019-12-18 00:51:03 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,862 bytes |
コンパイル時間 | 3,117 ms |
コンパイル使用メモリ | 79,388 KB |
実行使用メモリ | 51,600 KB |
最終ジャッジ日時 | 2024-07-07 00:01:36 |
合計ジャッジ時間 | 11,956 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 62 ms
51,384 KB |
testcase_01 | AC | 57 ms
50,388 KB |
testcase_02 | AC | 48 ms
50,356 KB |
testcase_03 | AC | 46 ms
49,964 KB |
testcase_04 | AC | 47 ms
49,920 KB |
testcase_05 | AC | 47 ms
50,304 KB |
testcase_06 | AC | 48 ms
50,268 KB |
testcase_07 | AC | 47 ms
50,304 KB |
testcase_08 | AC | 49 ms
50,332 KB |
testcase_09 | AC | 47 ms
50,328 KB |
testcase_10 | AC | 48 ms
50,336 KB |
testcase_11 | AC | 48 ms
50,028 KB |
testcase_12 | AC | 46 ms
50,296 KB |
testcase_13 | AC | 47 ms
50,356 KB |
testcase_14 | AC | 47 ms
50,256 KB |
testcase_15 | AC | 48 ms
50,032 KB |
testcase_16 | AC | 49 ms
50,456 KB |
testcase_17 | AC | 46 ms
50,296 KB |
testcase_18 | AC | 46 ms
49,964 KB |
testcase_19 | AC | 48 ms
49,884 KB |
testcase_20 | AC | 46 ms
49,888 KB |
testcase_21 | AC | 46 ms
50,252 KB |
testcase_22 | AC | 48 ms
50,172 KB |
testcase_23 | AC | 47 ms
49,944 KB |
testcase_24 | AC | 48 ms
50,336 KB |
testcase_25 | AC | 47 ms
50,148 KB |
testcase_26 | AC | 47 ms
50,408 KB |
testcase_27 | AC | 48 ms
50,440 KB |
testcase_28 | AC | 47 ms
50,232 KB |
testcase_29 | AC | 46 ms
50,364 KB |
testcase_30 | AC | 46 ms
50,096 KB |
testcase_31 | AC | 48 ms
50,344 KB |
testcase_32 | AC | 47 ms
50,288 KB |
testcase_33 | AC | 47 ms
50,284 KB |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | AC | 58 ms
51,040 KB |
testcase_38 | AC | 56 ms
51,112 KB |
testcase_39 | AC | 64 ms
51,228 KB |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | AC | 61 ms
51,072 KB |
testcase_44 | AC | 58 ms
51,188 KB |
testcase_45 | AC | 60 ms
51,128 KB |
testcase_46 | AC | 64 ms
51,072 KB |
testcase_47 | AC | 61 ms
51,444 KB |
testcase_48 | AC | 56 ms
51,172 KB |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | AC | 63 ms
51,460 KB |
testcase_53 | AC | 59 ms
51,388 KB |
testcase_54 | AC | 58 ms
51,080 KB |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | AC | 60 ms
51,196 KB |
testcase_59 | AC | 58 ms
50,988 KB |
testcase_60 | AC | 48 ms
50,088 KB |
testcase_61 | AC | 48 ms
49,956 KB |
testcase_62 | AC | 61 ms
51,408 KB |
testcase_63 | AC | 61 ms
51,360 KB |
testcase_64 | AC | 50 ms
50,008 KB |
testcase_65 | AC | 63 ms
51,284 KB |
testcase_66 | AC | 50 ms
50,376 KB |
testcase_67 | AC | 62 ms
51,156 KB |
testcase_68 | AC | 49 ms
49,920 KB |
testcase_69 | AC | 64 ms
51,172 KB |
testcase_70 | AC | 58 ms
51,096 KB |
testcase_71 | AC | 48 ms
50,052 KB |
testcase_72 | AC | 47 ms
50,304 KB |
testcase_73 | AC | 61 ms
51,124 KB |
testcase_74 | AC | 58 ms
50,728 KB |
testcase_75 | AC | 46 ms
50,316 KB |
testcase_76 | AC | 46 ms
50,336 KB |
testcase_77 | AC | 60 ms
51,600 KB |
testcase_78 | AC | 59 ms
51,064 KB |
testcase_79 | AC | 60 ms
50,848 KB |
testcase_80 | AC | 46 ms
50,272 KB |
testcase_81 | AC | 59 ms
51,492 KB |
testcase_82 | AC | 47 ms
50,344 KB |
testcase_83 | AC | 46 ms
50,256 KB |
testcase_84 | AC | 47 ms
50,276 KB |
testcase_85 | AC | 47 ms
50,356 KB |
testcase_86 | AC | 46 ms
50,036 KB |
testcase_87 | AC | 47 ms
50,308 KB |
testcase_88 | AC | 48 ms
50,360 KB |
testcase_89 | AC | 48 ms
50,064 KB |
testcase_90 | AC | 46 ms
50,016 KB |
testcase_91 | AC | 46 ms
50,292 KB |
testcase_92 | AC | 46 ms
50,040 KB |
testcase_93 | AC | 47 ms
50,468 KB |
testcase_94 | AC | 47 ms
50,344 KB |
testcase_95 | AC | 49 ms
50,200 KB |
testcase_96 | AC | 46 ms
50,492 KB |
testcase_97 | AC | 48 ms
50,356 KB |
testcase_98 | AC | 48 ms
49,988 KB |
testcase_99 | AC | 47 ms
50,288 KB |
testcase_100 | AC | 46 ms
50,348 KB |
testcase_101 | AC | 47 ms
50,076 KB |
testcase_102 | AC | 49 ms
50,324 KB |
testcase_103 | AC | 47 ms
50,352 KB |
testcase_104 | AC | 47 ms
50,344 KB |
testcase_105 | AC | 48 ms
50,352 KB |
testcase_106 | AC | 47 ms
50,440 KB |
testcase_107 | AC | 47 ms
50,272 KB |
testcase_108 | AC | 47 ms
50,340 KB |
testcase_109 | AC | 46 ms
50,408 KB |
testcase_110 | AC | 48 ms
50,292 KB |
testcase_111 | AC | 48 ms
50,112 KB |
testcase_112 | AC | 46 ms
50,000 KB |
testcase_113 | AC | 47 ms
50,292 KB |
testcase_114 | AC | 48 ms
50,088 KB |
testcase_115 | AC | 48 ms
50,096 KB |
testcase_116 | AC | 49 ms
50,288 KB |
testcase_117 | AC | 48 ms
49,964 KB |
testcase_118 | AC | 48 ms
50,516 KB |
testcase_119 | AC | 48 ms
50,024 KB |
testcase_120 | AC | 50 ms
50,280 KB |
testcase_121 | AC | 48 ms
50,336 KB |
testcase_122 | AC | 59 ms
51,128 KB |
testcase_123 | AC | 57 ms
51,036 KB |
testcase_124 | AC | 55 ms
51,056 KB |
ソースコード
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, 20, BigDecimal.ROUND_HALF_UP); BigDecimal ans2 = mb.add(sq).divide(two).divide(ba, 20, BigDecimal.ROUND_HALF_UP); 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); } } }