結果
問題 | No.955 ax^2+bx+c=0 |
ユーザー | agataYMGT |
提出日時 | 2019-12-28 11:13:48 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 150 ms / 2,000 ms |
コード長 | 1,706 bytes |
コンパイル時間 | 3,661 ms |
コンパイル使用メモリ | 78,276 KB |
実行使用メモリ | 42,184 KB |
最終ジャッジ日時 | 2024-10-11 07:06:17 |
合計ジャッジ時間 | 24,233 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 144 ms
41,812 KB |
testcase_01 | AC | 137 ms
41,532 KB |
testcase_02 | AC | 136 ms
41,544 KB |
testcase_03 | AC | 133 ms
41,572 KB |
testcase_04 | AC | 135 ms
41,196 KB |
testcase_05 | AC | 136 ms
41,356 KB |
testcase_06 | AC | 133 ms
41,288 KB |
testcase_07 | AC | 135 ms
41,436 KB |
testcase_08 | AC | 133 ms
41,276 KB |
testcase_09 | AC | 135 ms
41,436 KB |
testcase_10 | AC | 134 ms
41,548 KB |
testcase_11 | AC | 134 ms
41,600 KB |
testcase_12 | AC | 135 ms
41,492 KB |
testcase_13 | AC | 135 ms
41,456 KB |
testcase_14 | AC | 136 ms
41,240 KB |
testcase_15 | AC | 135 ms
41,572 KB |
testcase_16 | AC | 140 ms
41,260 KB |
testcase_17 | AC | 134 ms
41,372 KB |
testcase_18 | AC | 136 ms
41,476 KB |
testcase_19 | AC | 136 ms
41,420 KB |
testcase_20 | AC | 134 ms
41,584 KB |
testcase_21 | AC | 137 ms
41,780 KB |
testcase_22 | AC | 137 ms
41,236 KB |
testcase_23 | AC | 136 ms
41,588 KB |
testcase_24 | AC | 136 ms
41,796 KB |
testcase_25 | AC | 137 ms
41,676 KB |
testcase_26 | AC | 135 ms
41,488 KB |
testcase_27 | AC | 135 ms
41,344 KB |
testcase_28 | AC | 137 ms
41,764 KB |
testcase_29 | AC | 145 ms
41,924 KB |
testcase_30 | AC | 135 ms
41,324 KB |
testcase_31 | AC | 135 ms
41,832 KB |
testcase_32 | AC | 135 ms
41,436 KB |
testcase_33 | AC | 136 ms
41,228 KB |
testcase_34 | AC | 148 ms
41,912 KB |
testcase_35 | AC | 148 ms
41,752 KB |
testcase_36 | AC | 149 ms
41,692 KB |
testcase_37 | AC | 146 ms
41,856 KB |
testcase_38 | AC | 148 ms
41,568 KB |
testcase_39 | AC | 147 ms
41,932 KB |
testcase_40 | AC | 149 ms
41,912 KB |
testcase_41 | AC | 146 ms
41,752 KB |
testcase_42 | AC | 144 ms
41,760 KB |
testcase_43 | AC | 147 ms
41,576 KB |
testcase_44 | AC | 143 ms
41,832 KB |
testcase_45 | AC | 145 ms
41,612 KB |
testcase_46 | AC | 146 ms
41,648 KB |
testcase_47 | AC | 145 ms
41,516 KB |
testcase_48 | AC | 147 ms
41,852 KB |
testcase_49 | AC | 147 ms
41,812 KB |
testcase_50 | AC | 146 ms
41,704 KB |
testcase_51 | AC | 147 ms
41,628 KB |
testcase_52 | AC | 146 ms
42,184 KB |
testcase_53 | AC | 149 ms
41,724 KB |
testcase_54 | AC | 132 ms
40,612 KB |
testcase_55 | AC | 149 ms
41,944 KB |
testcase_56 | AC | 149 ms
42,020 KB |
testcase_57 | AC | 144 ms
41,776 KB |
testcase_58 | AC | 144 ms
41,640 KB |
testcase_59 | AC | 142 ms
41,752 KB |
testcase_60 | AC | 135 ms
41,732 KB |
testcase_61 | AC | 137 ms
41,540 KB |
testcase_62 | AC | 146 ms
41,868 KB |
testcase_63 | AC | 145 ms
41,440 KB |
testcase_64 | AC | 137 ms
41,804 KB |
testcase_65 | AC | 145 ms
41,456 KB |
testcase_66 | AC | 136 ms
41,648 KB |
testcase_67 | AC | 146 ms
42,064 KB |
testcase_68 | AC | 135 ms
41,600 KB |
testcase_69 | AC | 146 ms
41,688 KB |
testcase_70 | AC | 147 ms
41,936 KB |
testcase_71 | AC | 136 ms
41,356 KB |
testcase_72 | AC | 136 ms
41,384 KB |
testcase_73 | AC | 145 ms
41,620 KB |
testcase_74 | AC | 150 ms
41,704 KB |
testcase_75 | AC | 136 ms
41,640 KB |
testcase_76 | AC | 137 ms
41,528 KB |
testcase_77 | AC | 147 ms
41,796 KB |
testcase_78 | AC | 148 ms
41,760 KB |
testcase_79 | AC | 145 ms
41,652 KB |
testcase_80 | AC | 136 ms
41,224 KB |
testcase_81 | AC | 148 ms
41,760 KB |
testcase_82 | AC | 135 ms
41,836 KB |
testcase_83 | AC | 136 ms
41,484 KB |
testcase_84 | AC | 135 ms
41,556 KB |
testcase_85 | AC | 136 ms
41,412 KB |
testcase_86 | AC | 137 ms
41,860 KB |
testcase_87 | AC | 135 ms
41,596 KB |
testcase_88 | AC | 136 ms
41,692 KB |
testcase_89 | AC | 132 ms
41,584 KB |
testcase_90 | AC | 123 ms
41,400 KB |
testcase_91 | AC | 136 ms
41,524 KB |
testcase_92 | AC | 134 ms
41,472 KB |
testcase_93 | AC | 136 ms
41,700 KB |
testcase_94 | AC | 137 ms
41,568 KB |
testcase_95 | AC | 137 ms
41,496 KB |
testcase_96 | AC | 136 ms
41,520 KB |
testcase_97 | AC | 135 ms
41,688 KB |
testcase_98 | AC | 136 ms
41,704 KB |
testcase_99 | AC | 137 ms
41,668 KB |
testcase_100 | AC | 135 ms
41,552 KB |
testcase_101 | AC | 137 ms
41,108 KB |
testcase_102 | AC | 136 ms
41,624 KB |
testcase_103 | AC | 133 ms
41,864 KB |
testcase_104 | AC | 133 ms
41,900 KB |
testcase_105 | AC | 134 ms
41,456 KB |
testcase_106 | AC | 136 ms
41,700 KB |
testcase_107 | AC | 137 ms
41,416 KB |
testcase_108 | AC | 136 ms
41,380 KB |
testcase_109 | AC | 137 ms
41,508 KB |
testcase_110 | AC | 136 ms
41,868 KB |
testcase_111 | AC | 136 ms
41,816 KB |
testcase_112 | AC | 133 ms
41,596 KB |
testcase_113 | AC | 133 ms
41,464 KB |
testcase_114 | AC | 134 ms
41,704 KB |
testcase_115 | AC | 133 ms
41,356 KB |
testcase_116 | AC | 121 ms
41,556 KB |
testcase_117 | AC | 135 ms
41,708 KB |
testcase_118 | AC | 135 ms
41,548 KB |
testcase_119 | AC | 135 ms
41,632 KB |
testcase_120 | AC | 137 ms
41,652 KB |
testcase_121 | AC | 136 ms
41,536 KB |
testcase_122 | AC | 146 ms
41,632 KB |
testcase_123 | AC | 146 ms
41,972 KB |
testcase_124 | AC | 143 ms
41,864 KB |
ソースコード
import java.math.BigDecimal; import java.math.RoundingMode; import java.util.Scanner; public class No955 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); BigDecimal A = new BigDecimal(a); BigDecimal B = new BigDecimal(b); BigDecimal C = new BigDecimal(c); if(a == 0) { if(b == 0) { if(c == 0) { System.out.println(-1); return; } else { System.out.println(0); return; } } else { System.out.println(1); System.out.println(BigDecimal.ZERO.subtract(C).divide(B, 20, RoundingMode.HALF_EVEN)); return; } } BigDecimal D = new BigDecimal(b); D = D.multiply(B).subtract(new BigDecimal(4).multiply(A).multiply(C)); if(D.compareTo(BigDecimal.ZERO) == 1) { System.out.println(2); BigDecimal answer1 = BigDecimal.ZERO.subtract(B).subtract(sqrt(D)).divide(new BigDecimal(2).multiply(A), 20, RoundingMode.HALF_EVEN); BigDecimal answer2 = BigDecimal.ZERO.subtract(B).add(sqrt(D)).divide(new BigDecimal(2).multiply(A), 20, RoundingMode.HALF_EVEN); System.out.println(answer1.min(answer2)); System.out.println(answer1.max(answer2)); } else if(D.compareTo(BigDecimal.ZERO) == 0) { System.out.println(1); System.out.println(BigDecimal.ZERO.subtract(B).divide(new BigDecimal(2).multiply(A), 20, RoundingMode.HALF_EVEN)); } else { System.out.println(0); } } public static BigDecimal sqrt(BigDecimal a) { BigDecimal a2 = a.add(BigDecimal.ZERO); for(int i = 0; i < 50; i++) { a2 = a2.subtract(a2.pow(2).subtract(a).divide(a2.multiply(new BigDecimal(2)), 30, RoundingMode.HALF_EVEN)); } return a2; } }