結果
問題 | No.955 ax^2+bx+c=0 |
ユーザー | k_6101 |
提出日時 | 2019-12-21 16:17:57 |
言語 | Java21 (openjdk 21) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 3,208 bytes |
コンパイル時間 | 2,382 ms |
コンパイル使用メモリ | 102,968 KB |
実行使用メモリ | 41,868 KB |
最終ジャッジ日時 | 2024-09-18 22:17:42 |
合計ジャッジ時間 | 18,182 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 114 ms
41,588 KB |
testcase_01 | AC | 126 ms
39,972 KB |
testcase_02 | AC | 110 ms
41,124 KB |
testcase_03 | AC | 111 ms
40,888 KB |
testcase_04 | AC | 92 ms
40,152 KB |
testcase_05 | AC | 90 ms
39,844 KB |
testcase_06 | AC | 107 ms
41,064 KB |
testcase_07 | AC | 106 ms
41,252 KB |
testcase_08 | AC | 104 ms
41,084 KB |
testcase_09 | AC | 104 ms
41,064 KB |
testcase_10 | AC | 104 ms
41,136 KB |
testcase_11 | AC | 106 ms
40,924 KB |
testcase_12 | AC | 106 ms
41,164 KB |
testcase_13 | AC | 109 ms
41,180 KB |
testcase_14 | AC | 115 ms
41,240 KB |
testcase_15 | AC | 112 ms
41,300 KB |
testcase_16 | AC | 95 ms
40,192 KB |
testcase_17 | AC | 107 ms
40,940 KB |
testcase_18 | AC | 112 ms
41,072 KB |
testcase_19 | AC | 99 ms
40,132 KB |
testcase_20 | AC | 106 ms
40,980 KB |
testcase_21 | AC | 100 ms
40,844 KB |
testcase_22 | AC | 101 ms
40,180 KB |
testcase_23 | AC | 117 ms
41,472 KB |
testcase_24 | AC | 115 ms
41,508 KB |
testcase_25 | AC | 100 ms
40,020 KB |
testcase_26 | AC | 111 ms
41,152 KB |
testcase_27 | AC | 109 ms
41,128 KB |
testcase_28 | AC | 96 ms
39,964 KB |
testcase_29 | AC | 96 ms
40,156 KB |
testcase_30 | AC | 97 ms
39,920 KB |
testcase_31 | AC | 95 ms
40,196 KB |
testcase_32 | AC | 108 ms
41,288 KB |
testcase_33 | AC | 110 ms
40,844 KB |
testcase_34 | AC | 119 ms
41,584 KB |
testcase_35 | AC | 119 ms
41,820 KB |
testcase_36 | AC | 114 ms
41,740 KB |
testcase_37 | AC | 120 ms
41,748 KB |
testcase_38 | AC | 118 ms
41,700 KB |
testcase_39 | AC | 114 ms
41,676 KB |
testcase_40 | AC | 104 ms
40,644 KB |
testcase_41 | AC | 111 ms
41,228 KB |
testcase_42 | AC | 104 ms
40,516 KB |
testcase_43 | AC | 117 ms
41,540 KB |
testcase_44 | AC | 118 ms
41,396 KB |
testcase_45 | AC | 104 ms
40,328 KB |
testcase_46 | AC | 105 ms
40,872 KB |
testcase_47 | AC | 103 ms
40,628 KB |
testcase_48 | AC | 112 ms
41,536 KB |
testcase_49 | AC | 102 ms
40,480 KB |
testcase_50 | AC | 101 ms
40,360 KB |
testcase_51 | AC | 105 ms
40,376 KB |
testcase_52 | AC | 123 ms
41,568 KB |
testcase_53 | AC | 117 ms
41,560 KB |
testcase_54 | AC | 116 ms
41,664 KB |
testcase_55 | AC | 109 ms
40,340 KB |
testcase_56 | AC | 117 ms
41,592 KB |
testcase_57 | AC | 113 ms
41,236 KB |
testcase_58 | AC | 112 ms
41,176 KB |
testcase_59 | AC | 126 ms
41,760 KB |
testcase_60 | AC | 115 ms
41,144 KB |
testcase_61 | AC | 106 ms
40,968 KB |
testcase_62 | AC | 117 ms
41,868 KB |
testcase_63 | AC | 113 ms
41,456 KB |
testcase_64 | AC | 95 ms
40,024 KB |
testcase_65 | AC | 103 ms
40,588 KB |
testcase_66 | AC | 100 ms
40,352 KB |
testcase_67 | AC | 106 ms
40,748 KB |
testcase_68 | AC | 108 ms
40,844 KB |
testcase_69 | AC | 121 ms
41,636 KB |
testcase_70 | AC | 103 ms
40,600 KB |
testcase_71 | AC | 108 ms
41,268 KB |
testcase_72 | AC | 94 ms
41,520 KB |
testcase_73 | AC | 102 ms
40,644 KB |
testcase_74 | AC | 114 ms
41,692 KB |
testcase_75 | AC | 102 ms
40,948 KB |
testcase_76 | AC | 104 ms
41,060 KB |
testcase_77 | AC | 112 ms
41,576 KB |
testcase_78 | AC | 106 ms
40,968 KB |
testcase_79 | AC | 107 ms
40,496 KB |
testcase_80 | AC | 96 ms
40,020 KB |
testcase_81 | AC | 106 ms
41,036 KB |
testcase_82 | AC | 107 ms
40,892 KB |
testcase_83 | AC | 109 ms
41,144 KB |
testcase_84 | AC | 99 ms
40,132 KB |
testcase_85 | AC | 97 ms
40,176 KB |
testcase_86 | AC | 107 ms
41,180 KB |
testcase_87 | AC | 99 ms
40,532 KB |
testcase_88 | AC | 99 ms
40,484 KB |
testcase_89 | AC | 117 ms
41,240 KB |
testcase_90 | AC | 114 ms
41,256 KB |
testcase_91 | AC | 109 ms
41,000 KB |
testcase_92 | AC | 107 ms
41,048 KB |
testcase_93 | AC | 97 ms
40,272 KB |
testcase_94 | AC | 115 ms
41,028 KB |
testcase_95 | AC | 110 ms
40,996 KB |
testcase_96 | AC | 113 ms
41,240 KB |
testcase_97 | AC | 112 ms
41,068 KB |
testcase_98 | AC | 112 ms
41,092 KB |
testcase_99 | AC | 115 ms
41,292 KB |
testcase_100 | AC | 101 ms
40,248 KB |
testcase_101 | AC | 111 ms
41,152 KB |
testcase_102 | AC | 110 ms
41,116 KB |
testcase_103 | AC | 94 ms
39,868 KB |
testcase_104 | AC | 111 ms
41,020 KB |
testcase_105 | AC | 106 ms
40,132 KB |
testcase_106 | AC | 119 ms
41,116 KB |
testcase_107 | AC | 112 ms
41,516 KB |
testcase_108 | AC | 111 ms
41,380 KB |
testcase_109 | AC | 110 ms
41,316 KB |
testcase_110 | AC | 115 ms
41,208 KB |
testcase_111 | AC | 105 ms
40,984 KB |
testcase_112 | AC | 100 ms
40,228 KB |
testcase_113 | AC | 97 ms
40,332 KB |
testcase_114 | AC | 104 ms
40,892 KB |
testcase_115 | AC | 107 ms
41,180 KB |
testcase_116 | AC | 96 ms
40,124 KB |
testcase_117 | AC | 99 ms
40,276 KB |
testcase_118 | AC | 99 ms
40,096 KB |
testcase_119 | AC | 110 ms
41,424 KB |
testcase_120 | AC | 105 ms
41,072 KB |
testcase_121 | AC | 95 ms
39,996 KB |
testcase_122 | AC | 106 ms
40,572 KB |
testcase_123 | AC | 96 ms
40,364 KB |
testcase_124 | WA | - |
ソースコード
import java.io.InputStream; import java.io.PrintWriter; import java.lang.reflect.Array; import java.math.BigDecimal; import java.math.MathContext; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.PriorityQueue; import java.util.Queue; import java.util.Scanner; import java.util.Set; import java.util.Stack; import java.util.TreeMap; import java.util.TreeSet; import static java.util.Comparator.*; public class Main { public static void main(String[] args) { PrintWriter out = new PrintWriter(System.out); Solver solver = new Solver(System.in, out); solver.solve(); out.close(); } } class Solver { Scanner sc; PrintWriter out; public Solver(InputStream in, PrintWriter out) { sc = new Scanner(in); this.out = out; } // ================================================================== public void solve() { long A = Long.parseLong(sc.next()); long B = Long.parseLong(sc.next()); long C = Long.parseLong(sc.next()); if(A == 0 && B == 0) { if(C == 0) out.println(-1); else out.println(0); } else if(A == 0) { out.println(1); out.println(String.format("%.14f", (double)C * -1 /B)); } else if(B == 0) { if(C == 0) { out.println(1); out.println(0); } else if((long)A * C < 0) { out.println(0); } else { double X = Math.sqrt((double)C*-1/A); out.println(2); out.println("-" + String.format("%.14f", X)); out.println(String.format("%.14f", X)); } } else if(C == 0) { out.println(2); if(B > 0) { out.println(String.format("%.14f", (double)B * -1 / A)); out.println(0); } else { out.println(0); out.println(String.format("%.14f", (double)B * -1 / A)); } } else if((B*B - 4*A*C) < 0) { out.println(0); } else { if((B*B - 4*A*C) == 0) { out.println(1); out.println(String.format("%.14f", ((double)B * -1) / A / 2)); } else { BigDecimal wk = sqrt(B*B - 4*A*C); out.println(2); if(A > 0) { out.println(String.format("%.14f", (new BigDecimal(B).negate().subtract(wk).divide(new BigDecimal(A*2),14,BigDecimal.ROUND_UP)))); out.println(String.format("%.14f", (new BigDecimal(B).negate().add(wk).divide(new BigDecimal(A*2),14,BigDecimal.ROUND_UP)))); } else { out.println(String.format("%.14f", (new BigDecimal(B).negate().add(wk).divide(new BigDecimal(A*2),14,BigDecimal.ROUND_UP)))); out.println(String.format("%.14f", (new BigDecimal(B).negate().subtract(wk).divide(new BigDecimal(A*2),14,BigDecimal.ROUND_UP)))); } } } } BigDecimal sqrt(long a) { MathContext cx = new MathContext(20); BigDecimal cur = BigDecimal.ONE; // (x+a/x)/2 for(int rep = 0;rep < 50;rep++){ cur = cur.add(BigDecimal.valueOf(a).divide(cur, cx)).divide(BigDecimal.valueOf(2), cx); } return cur; } }