結果
問題 | No.955 ax^2+bx+c=0 |
ユーザー | Suunn |
提出日時 | 2020-05-07 07:50:03 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 5,827 bytes |
コンパイル時間 | 2,466 ms |
コンパイル使用メモリ | 90,616 KB |
実行使用メモリ | 54,908 KB |
最終ジャッジ日時 | 2024-07-03 09:18:05 |
合計ジャッジ時間 | 18,323 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | AC | 51 ms
49,852 KB |
testcase_03 | WA | - |
testcase_04 | AC | 52 ms
50,076 KB |
testcase_05 | AC | 53 ms
50,000 KB |
testcase_06 | AC | 54 ms
50,248 KB |
testcase_07 | AC | 52 ms
50,272 KB |
testcase_08 | AC | 54 ms
50,272 KB |
testcase_09 | AC | 53 ms
49,952 KB |
testcase_10 | AC | 52 ms
50,120 KB |
testcase_11 | AC | 56 ms
50,288 KB |
testcase_12 | AC | 53 ms
50,024 KB |
testcase_13 | AC | 53 ms
50,256 KB |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
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 | AC | 52 ms
50,424 KB |
testcase_61 | AC | 52 ms
50,076 KB |
testcase_62 | WA | - |
testcase_63 | WA | - |
testcase_64 | AC | 53 ms
50,140 KB |
testcase_65 | WA | - |
testcase_66 | AC | 53 ms
50,016 KB |
testcase_67 | WA | - |
testcase_68 | AC | 52 ms
50,280 KB |
testcase_69 | WA | - |
testcase_70 | WA | - |
testcase_71 | AC | 52 ms
49,844 KB |
testcase_72 | AC | 52 ms
50,248 KB |
testcase_73 | WA | - |
testcase_74 | WA | - |
testcase_75 | AC | 53 ms
50,040 KB |
testcase_76 | AC | 51 ms
50,104 KB |
testcase_77 | WA | - |
testcase_78 | WA | - |
testcase_79 | WA | - |
testcase_80 | AC | 52 ms
50,156 KB |
testcase_81 | WA | - |
testcase_82 | WA | - |
testcase_83 | WA | - |
testcase_84 | WA | - |
testcase_85 | WA | - |
testcase_86 | WA | - |
testcase_87 | WA | - |
testcase_88 | WA | - |
testcase_89 | WA | - |
testcase_90 | WA | - |
testcase_91 | WA | - |
testcase_92 | AC | 55 ms
50,016 KB |
testcase_93 | AC | 56 ms
50,072 KB |
testcase_94 | WA | - |
testcase_95 | WA | - |
testcase_96 | WA | - |
testcase_97 | WA | - |
testcase_98 | WA | - |
testcase_99 | WA | - |
testcase_100 | AC | 56 ms
49,704 KB |
testcase_101 | WA | - |
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 | WA | - |
testcase_123 | WA | - |
testcase_124 | WA | - |
ソースコード
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.NoSuchElementException; import java.util.Queue; import java.util.Scanner; import java.util.TreeMap; import java.util.TreeSet; public class Main { static MLScanner sc = new MLScanner(System.in); static PrintWriter ot = new PrintWriter(System.out); static String sp = " "; public static void main(String[] args) { int T = 1; for(int i=0;i<T;i++) { long A = sc.nextLong(); long B = sc.nextLong(); long C = sc.nextLong(); double a = A; double b = B; double c = C; if(A==0&&B==0) { if(C==0)ot.println(3); else ot.println(0); }else if(A==0) { ot.println(1+sp+(-c/b)); }else { if(B<0) { A *= -1; B *= -1; C *= -1; a *= -1; b *= -1; c *= -1; } long D = B*B-4*A*C; if(D<0) ot.println(0); else if(D==0)ot.println(1+sp+(-b/(2*a))); else { double ans1 = -(b+Math.sqrt(D))/(2*a); double ans2 = -(B*B-D)/(2*a*(b+Math.sqrt(D))); if(ans1>ans2) { double tmp = ans1; ans1 = ans2; ans2 = tmp; } ot.printf("%d%s%.10f%s%.10f",2,sp,ans1,sp,ans2); ot.println(); } } } ot.flush(); } } class MLScanner { private static final int BUFFER_SIZE = 1024; private final InputStream stream; private final byte[] buffer; private int pointer; private int bufferLength; MLScanner(InputStream stream) { this.stream = stream; this.buffer = new byte[BUFFER_SIZE]; this.pointer = 0; this.bufferLength = 0; } private boolean hasNextByte() { if (pointer < bufferLength) { return true; } pointer = 0; try { bufferLength = stream.read(buffer); } catch (IOException e) { throw new RuntimeException(e); } return bufferLength > 0; } private int readByte() { if (hasNextByte()) { return buffer[pointer++]; } else { return -1; } } private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126; } public boolean hasNext() { while (hasNextByte() && !isPrintableChar(buffer[pointer])) { pointer++; } return hasNextByte(); } public String next() { if (!hasNext()) { throw new NoSuchElementException(); } StringBuilder sb = new StringBuilder(); while(true) { int b = readByte(); if (!isPrintableChar(b)) { break; } sb.appendCodePoint(b); } return sb.toString(); } public char nextChar() { return next().charAt(0); } public int nextInt() { long nl = nextLong(); if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) { throw new NumberFormatException(); } return (int) nl; } public long nextLong() { if (!hasNext()) { throw new NoSuchElementException(); } long n = 0; boolean minus = false; { int b = readByte(); if (b == '-') { minus = true; } else if ('0' <= b && b <= '9') { n = b - '0'; } else { throw new NumberFormatException(); } } while(true){ int b = readByte(); if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; } else if (b == -1 || !isPrintableChar(b)) { return minus ? -n : n; } else { throw new NumberFormatException(); } } } public double nextDouble() { return Double.parseDouble(next()); } public String[] next(int n) { String[] array = new String[n]; for (int i = 0; i < n; i++) { array[i] = next(); } return array; } public char[] nextChar(int n) { char[] array = new char[n]; for (int i = 0; i < n; i++) { array[i] = nextChar(); } return array; } public int[] nextInt(int n) { int[] array = new int[n]; for (int i = 0; i < n; i++) { array[i] = nextInt(); } return array; } public long[] nextLong(int n) { long[] array = new long[n]; for (int i = 0; i < n; i++) { array[i] = nextLong(); } return array; } public double[] nextDouble(int n) { double[] array = new double[n]; for (int i = 0; i < n; i++) { array[i] = nextDouble(); } return array; } public char[] nextCharArray() { return next().toCharArray(); } public int[][] nextInt(int n, int m) { int[][] matrix = new int[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { matrix[i][j] = nextInt(); } } return matrix; } public char[][] nextChar(int n, int m) { char[][] matrix = new char[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { matrix[i][j] = nextChar(); } } return matrix; } public long[][] nextLong(int n, int m) { long[][] matrix = new long[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { matrix[i][j] = nextLong(); } } return matrix; } public double[][] nextDouble(int n, int m) { double[][] matrix = new double[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { matrix[i][j] = nextDouble(); } } return matrix; } public char[][] nextCharArray(int n) { char[][] matrix = new char[n][]; for (int i = 0; i < n; i++) { matrix[i] = next().toCharArray(); } return matrix; } }