結果
問題 | No.955 ax^2+bx+c=0 |
ユーザー | agataYMGT |
提出日時 | 2019-12-28 11:05:32 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,552 bytes |
コンパイル時間 | 3,631 ms |
コンパイル使用メモリ | 78,848 KB |
実行使用メモリ | 56,372 KB |
最終ジャッジ日時 | 2024-10-11 07:04:59 |
合計ジャッジ時間 | 24,052 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 147 ms
42,084 KB |
testcase_01 | AC | 135 ms
41,228 KB |
testcase_02 | AC | 132 ms
41,396 KB |
testcase_03 | AC | 133 ms
41,400 KB |
testcase_04 | AC | 135 ms
41,532 KB |
testcase_05 | AC | 135 ms
41,628 KB |
testcase_06 | AC | 136 ms
41,640 KB |
testcase_07 | AC | 136 ms
41,272 KB |
testcase_08 | AC | 137 ms
41,568 KB |
testcase_09 | AC | 135 ms
41,276 KB |
testcase_10 | AC | 137 ms
41,408 KB |
testcase_11 | AC | 134 ms
41,292 KB |
testcase_12 | AC | 136 ms
41,276 KB |
testcase_13 | AC | 137 ms
41,472 KB |
testcase_14 | AC | 133 ms
41,264 KB |
testcase_15 | AC | 134 ms
41,280 KB |
testcase_16 | AC | 133 ms
41,416 KB |
testcase_17 | AC | 133 ms
41,376 KB |
testcase_18 | AC | 133 ms
41,556 KB |
testcase_19 | AC | 134 ms
41,420 KB |
testcase_20 | AC | 135 ms
41,632 KB |
testcase_21 | AC | 133 ms
41,196 KB |
testcase_22 | AC | 134 ms
41,428 KB |
testcase_23 | AC | 134 ms
41,540 KB |
testcase_24 | AC | 134 ms
41,484 KB |
testcase_25 | AC | 135 ms
41,404 KB |
testcase_26 | AC | 135 ms
41,592 KB |
testcase_27 | AC | 135 ms
41,668 KB |
testcase_28 | AC | 135 ms
41,688 KB |
testcase_29 | AC | 134 ms
41,668 KB |
testcase_30 | AC | 139 ms
41,752 KB |
testcase_31 | AC | 137 ms
41,532 KB |
testcase_32 | AC | 136 ms
41,404 KB |
testcase_33 | AC | 134 ms
41,664 KB |
testcase_34 | AC | 154 ms
42,032 KB |
testcase_35 | AC | 154 ms
41,684 KB |
testcase_36 | AC | 153 ms
41,932 KB |
testcase_37 | AC | 152 ms
41,652 KB |
testcase_38 | AC | 158 ms
41,808 KB |
testcase_39 | AC | 159 ms
41,884 KB |
testcase_40 | AC | 154 ms
41,636 KB |
testcase_41 | AC | 156 ms
41,708 KB |
testcase_42 | AC | 154 ms
41,928 KB |
testcase_43 | AC | 155 ms
42,392 KB |
testcase_44 | AC | 154 ms
41,532 KB |
testcase_45 | AC | 153 ms
42,040 KB |
testcase_46 | WA | - |
testcase_47 | WA | - |
testcase_48 | WA | - |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | WA | - |
testcase_52 | WA | - |
testcase_53 | WA | - |
testcase_54 | WA | - |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | AC | 146 ms
41,864 KB |
testcase_59 | WA | - |
testcase_60 | AC | 139 ms
41,372 KB |
testcase_61 | AC | 136 ms
41,428 KB |
testcase_62 | AC | 157 ms
41,584 KB |
testcase_63 | WA | - |
testcase_64 | AC | 135 ms
41,288 KB |
testcase_65 | WA | - |
testcase_66 | AC | 137 ms
41,056 KB |
testcase_67 | AC | 156 ms
41,896 KB |
testcase_68 | AC | 136 ms
41,052 KB |
testcase_69 | AC | 155 ms
41,940 KB |
testcase_70 | WA | - |
testcase_71 | AC | 135 ms
41,148 KB |
testcase_72 | AC | 134 ms
41,372 KB |
testcase_73 | AC | 154 ms
41,884 KB |
testcase_74 | AC | 156 ms
42,080 KB |
testcase_75 | AC | 137 ms
41,284 KB |
testcase_76 | AC | 136 ms
41,308 KB |
testcase_77 | WA | - |
testcase_78 | WA | - |
testcase_79 | WA | - |
testcase_80 | AC | 134 ms
41,512 KB |
testcase_81 | AC | 155 ms
41,780 KB |
testcase_82 | AC | 137 ms
41,204 KB |
testcase_83 | AC | 138 ms
41,304 KB |
testcase_84 | AC | 137 ms
41,424 KB |
testcase_85 | AC | 138 ms
41,680 KB |
testcase_86 | AC | 136 ms
41,432 KB |
testcase_87 | AC | 135 ms
41,248 KB |
testcase_88 | AC | 135 ms
41,656 KB |
testcase_89 | AC | 136 ms
41,356 KB |
testcase_90 | AC | 137 ms
41,228 KB |
testcase_91 | AC | 137 ms
41,512 KB |
testcase_92 | AC | 136 ms
41,536 KB |
testcase_93 | AC | 137 ms
41,428 KB |
testcase_94 | AC | 138 ms
41,436 KB |
testcase_95 | AC | 137 ms
41,416 KB |
testcase_96 | AC | 124 ms
41,412 KB |
testcase_97 | AC | 135 ms
41,616 KB |
testcase_98 | AC | 136 ms
41,420 KB |
testcase_99 | AC | 141 ms
41,332 KB |
testcase_100 | AC | 133 ms
41,536 KB |
testcase_101 | AC | 136 ms
41,500 KB |
testcase_102 | WA | - |
testcase_103 | WA | - |
testcase_104 | WA | - |
testcase_105 | WA | - |
testcase_106 | WA | - |
testcase_107 | WA | - |
testcase_108 | WA | - |
testcase_109 | WA | - |
testcase_110 | WA | - |
testcase_111 | WA | - |
testcase_112 | WA | - |
testcase_113 | WA | - |
testcase_114 | WA | - |
testcase_115 | WA | - |
testcase_116 | WA | - |
testcase_117 | WA | - |
testcase_118 | WA | - |
testcase_119 | WA | - |
testcase_120 | WA | - |
testcase_121 | WA | - |
testcase_122 | AC | 152 ms
41,884 KB |
testcase_123 | AC | 154 ms
41,764 KB |
testcase_124 | WA | - |
ソースコード
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(); 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(-c); return; } } BigDecimal A = new BigDecimal(a); BigDecimal B = new BigDecimal(b); BigDecimal C = new BigDecimal(c); 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); System.out.println(BigDecimal.ZERO.subtract(B).subtract(sqrt(D)).divide(new BigDecimal(2).multiply(A), 20, RoundingMode.HALF_EVEN)); System.out.println(BigDecimal.ZERO.subtract(B).add(sqrt(D)).divide(new BigDecimal(2).multiply(A), 20, RoundingMode.HALF_EVEN)); } 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 < 100; i++) { a2 = a2.subtract(a2.pow(2).subtract(a).divide(a2.multiply(new BigDecimal(2)), 20, RoundingMode.HALF_EVEN)); } return a2; } }