結果
問題 | No.955 ax^2+bx+c=0 |
ユーザー | agataYMGT |
提出日時 | 2019-12-28 11:10:54 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,644 bytes |
コンパイル時間 | 3,884 ms |
コンパイル使用メモリ | 78,736 KB |
実行使用メモリ | 42,312 KB |
最終ジャッジ日時 | 2024-10-11 07:05:45 |
合計ジャッジ時間 | 22,716 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 135 ms
41,804 KB |
testcase_01 | AC | 128 ms
41,604 KB |
testcase_02 | AC | 125 ms
41,792 KB |
testcase_03 | AC | 126 ms
41,612 KB |
testcase_04 | AC | 124 ms
41,448 KB |
testcase_05 | AC | 122 ms
41,576 KB |
testcase_06 | AC | 123 ms
41,460 KB |
testcase_07 | AC | 126 ms
41,580 KB |
testcase_08 | AC | 127 ms
41,560 KB |
testcase_09 | AC | 122 ms
41,220 KB |
testcase_10 | AC | 112 ms
41,408 KB |
testcase_11 | AC | 125 ms
41,340 KB |
testcase_12 | AC | 127 ms
41,612 KB |
testcase_13 | AC | 124 ms
41,592 KB |
testcase_14 | AC | 125 ms
41,448 KB |
testcase_15 | AC | 129 ms
41,416 KB |
testcase_16 | AC | 132 ms
41,604 KB |
testcase_17 | AC | 125 ms
41,564 KB |
testcase_18 | AC | 129 ms
41,592 KB |
testcase_19 | AC | 126 ms
41,516 KB |
testcase_20 | AC | 111 ms
41,632 KB |
testcase_21 | AC | 129 ms
41,252 KB |
testcase_22 | AC | 129 ms
41,544 KB |
testcase_23 | AC | 137 ms
41,696 KB |
testcase_24 | AC | 127 ms
41,260 KB |
testcase_25 | AC | 128 ms
41,856 KB |
testcase_26 | AC | 121 ms
40,452 KB |
testcase_27 | AC | 125 ms
41,804 KB |
testcase_28 | AC | 125 ms
41,580 KB |
testcase_29 | AC | 127 ms
41,676 KB |
testcase_30 | AC | 124 ms
41,544 KB |
testcase_31 | AC | 127 ms
41,576 KB |
testcase_32 | AC | 122 ms
41,392 KB |
testcase_33 | AC | 128 ms
41,840 KB |
testcase_34 | AC | 141 ms
41,800 KB |
testcase_35 | AC | 136 ms
41,796 KB |
testcase_36 | AC | 142 ms
41,928 KB |
testcase_37 | AC | 135 ms
42,004 KB |
testcase_38 | AC | 125 ms
42,284 KB |
testcase_39 | AC | 137 ms
41,448 KB |
testcase_40 | AC | 126 ms
41,776 KB |
testcase_41 | AC | 136 ms
41,516 KB |
testcase_42 | AC | 138 ms
41,772 KB |
testcase_43 | AC | 135 ms
41,632 KB |
testcase_44 | AC | 135 ms
41,588 KB |
testcase_45 | AC | 141 ms
41,720 KB |
testcase_46 | AC | 142 ms
41,740 KB |
testcase_47 | AC | 138 ms
41,728 KB |
testcase_48 | AC | 140 ms
41,808 KB |
testcase_49 | AC | 141 ms
41,688 KB |
testcase_50 | AC | 141 ms
41,652 KB |
testcase_51 | AC | 140 ms
41,592 KB |
testcase_52 | AC | 125 ms
41,888 KB |
testcase_53 | AC | 139 ms
41,648 KB |
testcase_54 | AC | 141 ms
41,888 KB |
testcase_55 | AC | 139 ms
41,464 KB |
testcase_56 | AC | 140 ms
41,908 KB |
testcase_57 | AC | 119 ms
41,500 KB |
testcase_58 | AC | 133 ms
41,832 KB |
testcase_59 | AC | 119 ms
41,820 KB |
testcase_60 | AC | 128 ms
41,504 KB |
testcase_61 | AC | 129 ms
41,492 KB |
testcase_62 | AC | 125 ms
42,000 KB |
testcase_63 | AC | 129 ms
40,208 KB |
testcase_64 | AC | 125 ms
42,008 KB |
testcase_65 | AC | 124 ms
41,664 KB |
testcase_66 | AC | 128 ms
41,476 KB |
testcase_67 | AC | 138 ms
41,420 KB |
testcase_68 | AC | 127 ms
41,340 KB |
testcase_69 | AC | 137 ms
41,640 KB |
testcase_70 | AC | 134 ms
41,788 KB |
testcase_71 | AC | 126 ms
41,904 KB |
testcase_72 | AC | 125 ms
41,252 KB |
testcase_73 | AC | 133 ms
42,312 KB |
testcase_74 | AC | 136 ms
41,672 KB |
testcase_75 | AC | 122 ms
41,372 KB |
testcase_76 | AC | 126 ms
41,404 KB |
testcase_77 | AC | 135 ms
41,688 KB |
testcase_78 | AC | 140 ms
41,724 KB |
testcase_79 | AC | 125 ms
41,672 KB |
testcase_80 | AC | 129 ms
41,264 KB |
testcase_81 | AC | 143 ms
41,748 KB |
testcase_82 | AC | 130 ms
41,804 KB |
testcase_83 | AC | 130 ms
41,404 KB |
testcase_84 | AC | 130 ms
41,280 KB |
testcase_85 | AC | 129 ms
41,428 KB |
testcase_86 | AC | 126 ms
41,428 KB |
testcase_87 | AC | 124 ms
41,664 KB |
testcase_88 | AC | 130 ms
41,632 KB |
testcase_89 | AC | 126 ms
41,468 KB |
testcase_90 | AC | 129 ms
41,312 KB |
testcase_91 | AC | 122 ms
40,188 KB |
testcase_92 | AC | 128 ms
41,784 KB |
testcase_93 | AC | 126 ms
41,704 KB |
testcase_94 | AC | 130 ms
41,504 KB |
testcase_95 | AC | 129 ms
41,688 KB |
testcase_96 | AC | 132 ms
41,744 KB |
testcase_97 | AC | 127 ms
41,728 KB |
testcase_98 | AC | 128 ms
41,572 KB |
testcase_99 | AC | 131 ms
41,576 KB |
testcase_100 | AC | 128 ms
41,108 KB |
testcase_101 | AC | 130 ms
41,364 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 | 137 ms
41,492 KB |
testcase_123 | AC | 137 ms
41,880 KB |
testcase_124 | AC | 139 ms
41,704 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(); 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); 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; } }