結果

問題 No.955 ax^2+bx+c=0
ユーザー C_nena_EC_nena_E
提出日時 2020-01-18 09:55:48
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,904 bytes
コンパイル時間 2,084 ms
コンパイル使用メモリ 74,340 KB
実行使用メモリ 58,764 KB
最終ジャッジ日時 2023-09-09 08:51:41
合計ジャッジ時間 22,400 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
56,356 KB
testcase_01 AC 125 ms
56,168 KB
testcase_02 AC 131 ms
56,696 KB
testcase_03 AC 126 ms
55,828 KB
testcase_04 AC 122 ms
55,980 KB
testcase_05 AC 127 ms
56,092 KB
testcase_06 AC 129 ms
56,352 KB
testcase_07 AC 124 ms
55,884 KB
testcase_08 AC 129 ms
56,676 KB
testcase_09 AC 123 ms
54,544 KB
testcase_10 AC 123 ms
56,104 KB
testcase_11 AC 127 ms
55,740 KB
testcase_12 AC 125 ms
56,004 KB
testcase_13 AC 125 ms
56,500 KB
testcase_14 AC 127 ms
56,392 KB
testcase_15 AC 122 ms
56,032 KB
testcase_16 AC 127 ms
56,332 KB
testcase_17 AC 126 ms
56,260 KB
testcase_18 AC 125 ms
56,160 KB
testcase_19 AC 123 ms
55,988 KB
testcase_20 AC 134 ms
56,420 KB
testcase_21 AC 124 ms
55,988 KB
testcase_22 AC 124 ms
56,036 KB
testcase_23 AC 127 ms
56,476 KB
testcase_24 AC 126 ms
57,680 KB
testcase_25 AC 126 ms
55,660 KB
testcase_26 AC 132 ms
56,264 KB
testcase_27 AC 129 ms
56,052 KB
testcase_28 AC 124 ms
56,028 KB
testcase_29 AC 126 ms
56,208 KB
testcase_30 AC 132 ms
56,212 KB
testcase_31 AC 130 ms
55,868 KB
testcase_32 AC 135 ms
56,236 KB
testcase_33 AC 131 ms
55,664 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
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 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 AC 129 ms
56,844 KB
testcase_63 AC 136 ms
56,628 KB
testcase_64 AC 132 ms
56,376 KB
testcase_65 AC 127 ms
55,808 KB
testcase_66 AC 136 ms
56,620 KB
testcase_67 AC 128 ms
56,824 KB
testcase_68 AC 127 ms
56,172 KB
testcase_69 AC 125 ms
56,536 KB
testcase_70 AC 129 ms
56,512 KB
testcase_71 AC 127 ms
56,484 KB
testcase_72 AC 126 ms
56,124 KB
testcase_73 AC 127 ms
56,244 KB
testcase_74 AC 133 ms
56,672 KB
testcase_75 AC 130 ms
56,504 KB
testcase_76 AC 126 ms
56,244 KB
testcase_77 AC 130 ms
56,704 KB
testcase_78 AC 131 ms
56,652 KB
testcase_79 AC 127 ms
56,132 KB
testcase_80 AC 125 ms
56,396 KB
testcase_81 AC 126 ms
55,920 KB
testcase_82 AC 124 ms
55,892 KB
testcase_83 AC 129 ms
56,032 KB
testcase_84 AC 123 ms
55,980 KB
testcase_85 AC 128 ms
56,484 KB
testcase_86 AC 132 ms
56,216 KB
testcase_87 AC 126 ms
56,064 KB
testcase_88 AC 129 ms
56,176 KB
testcase_89 AC 131 ms
55,916 KB
testcase_90 AC 128 ms
56,196 KB
testcase_91 AC 127 ms
56,216 KB
testcase_92 AC 130 ms
56,128 KB
testcase_93 AC 126 ms
56,132 KB
testcase_94 AC 128 ms
56,132 KB
testcase_95 AC 127 ms
56,000 KB
testcase_96 AC 128 ms
55,760 KB
testcase_97 AC 129 ms
56,364 KB
testcase_98 AC 130 ms
56,232 KB
testcase_99 AC 137 ms
55,988 KB
testcase_100 AC 127 ms
56,336 KB
testcase_101 AC 127 ms
55,904 KB
testcase_102 AC 126 ms
56,284 KB
testcase_103 AC 127 ms
56,180 KB
testcase_104 AC 126 ms
56,196 KB
testcase_105 AC 129 ms
56,212 KB
testcase_106 AC 126 ms
55,896 KB
testcase_107 AC 129 ms
55,740 KB
testcase_108 AC 129 ms
56,264 KB
testcase_109 AC 130 ms
54,244 KB
testcase_110 AC 129 ms
55,924 KB
testcase_111 AC 130 ms
56,460 KB
testcase_112 AC 129 ms
56,476 KB
testcase_113 AC 128 ms
56,576 KB
testcase_114 AC 131 ms
56,488 KB
testcase_115 AC 128 ms
55,916 KB
testcase_116 AC 130 ms
56,444 KB
testcase_117 AC 131 ms
55,968 KB
testcase_118 AC 133 ms
56,596 KB
testcase_119 AC 129 ms
57,872 KB
testcase_120 AC 127 ms
55,872 KB
testcase_121 AC 131 ms
56,572 KB
testcase_122 WA -
testcase_123 WA -
testcase_124 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        double a = sc.nextDouble();
        double b = sc.nextDouble();
        double c = sc.nextDouble();
        if(a == 0 && b == 0 && c == 0){
            System.out.println(-1);
            return;
        }else if(a == 0 && b == 0){
            System.out.println(0);
            return;
        }else if((a == 0 && c == 0) || (b == 0 && c == 0)){
            System.out.println(1);
            System.out.println(0);
            return;
        }else if(a == 0){
            System.out.println(1);
            System.out.println(-c/b);
            return;
        }else if(b == 0){
            if(c > 0){
                System.out.println(0);
            }else{
                System.out.println(2);
                double ans = Math.pow(-c,0.5);
                System.out.println(-ans);
                System.out.println(ans);
            }
            return;
        }else if(c == 0){
            System.out.println(2);
            if(b < 0){
                System.out.println(0);
                System.out.println(-b);
            }else{
                System.out.println(-b);
                System.out.println(0);
            }
            return;
        }
        double chk = b*b - (4*a*c);

        if(chk < 0){
            System.out.println(0);
        }else if(chk == 0){
            System.out.println(1);
            System.out.println(-b/(2*a));
        }else{
            System.out.println(2);
            double[] ans = new double[2];
            ans[0] = (-b-Math.pow(chk,0.5))/(2*a);
            ans[1] = (-b+Math.pow(chk,0.5))/(2*a);
            Arrays.sort(ans);
            for(int i = 0; i < 2; i++){
                System.out.println(ans[i]);
            }
        }
    }
}

0