結果
問題 | No.955 ax^2+bx+c=0 |
ユーザー | yakamoto |
提出日時 | 2019-12-23 22:54:03 |
言語 | Scala(Beta) (3.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,777 bytes |
コンパイル時間 | 14,847 ms |
コンパイル使用メモリ | 269,324 KB |
実行使用メモリ | 64,036 KB |
最終ジャッジ日時 | 2024-09-19 03:20:12 |
合計ジャッジ時間 | 135,505 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 974 ms
63,868 KB |
testcase_01 | AC | 954 ms
63,940 KB |
testcase_02 | AC | 856 ms
62,256 KB |
testcase_03 | AC | 858 ms
62,124 KB |
testcase_04 | AC | 861 ms
62,132 KB |
testcase_05 | AC | 858 ms
61,960 KB |
testcase_06 | AC | 855 ms
61,976 KB |
testcase_07 | AC | 853 ms
62,048 KB |
testcase_08 | AC | 844 ms
61,928 KB |
testcase_09 | AC | 862 ms
61,952 KB |
testcase_10 | AC | 865 ms
61,796 KB |
testcase_11 | AC | 862 ms
62,180 KB |
testcase_12 | AC | 865 ms
61,960 KB |
testcase_13 | AC | 863 ms
62,048 KB |
testcase_14 | AC | 964 ms
63,712 KB |
testcase_15 | AC | 965 ms
63,392 KB |
testcase_16 | AC | 956 ms
63,324 KB |
testcase_17 | AC | 964 ms
63,612 KB |
testcase_18 | AC | 959 ms
63,592 KB |
testcase_19 | AC | 946 ms
63,780 KB |
testcase_20 | AC | 950 ms
63,696 KB |
testcase_21 | AC | 952 ms
63,632 KB |
testcase_22 | AC | 981 ms
63,860 KB |
testcase_23 | AC | 966 ms
63,616 KB |
testcase_24 | AC | 959 ms
63,760 KB |
testcase_25 | AC | 966 ms
63,392 KB |
testcase_26 | AC | 948 ms
63,688 KB |
testcase_27 | AC | 956 ms
63,760 KB |
testcase_28 | AC | 956 ms
63,676 KB |
testcase_29 | AC | 958 ms
63,448 KB |
testcase_30 | AC | 956 ms
63,676 KB |
testcase_31 | AC | 969 ms
63,580 KB |
testcase_32 | AC | 960 ms
63,920 KB |
testcase_33 | AC | 956 ms
63,392 KB |
testcase_34 | AC | 956 ms
64,032 KB |
testcase_35 | AC | 958 ms
63,924 KB |
testcase_36 | AC | 970 ms
63,880 KB |
testcase_37 | AC | 968 ms
63,848 KB |
testcase_38 | AC | 964 ms
63,684 KB |
testcase_39 | AC | 962 ms
63,540 KB |
testcase_40 | AC | 942 ms
63,756 KB |
testcase_41 | AC | 969 ms
63,568 KB |
testcase_42 | AC | 957 ms
63,484 KB |
testcase_43 | AC | 962 ms
64,008 KB |
testcase_44 | AC | 975 ms
63,764 KB |
testcase_45 | AC | 978 ms
63,428 KB |
testcase_46 | AC | 953 ms
63,716 KB |
testcase_47 | AC | 960 ms
63,796 KB |
testcase_48 | AC | 972 ms
63,836 KB |
testcase_49 | AC | 965 ms
63,760 KB |
testcase_50 | AC | 966 ms
63,560 KB |
testcase_51 | AC | 965 ms
63,772 KB |
testcase_52 | AC | 957 ms
63,868 KB |
testcase_53 | AC | 970 ms
63,660 KB |
testcase_54 | AC | 951 ms
63,616 KB |
testcase_55 | AC | 974 ms
63,836 KB |
testcase_56 | AC | 987 ms
63,756 KB |
testcase_57 | AC | 967 ms
63,776 KB |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | AC | 857 ms
61,884 KB |
testcase_61 | AC | 866 ms
62,208 KB |
testcase_62 | WA | - |
testcase_63 | WA | - |
testcase_64 | AC | 863 ms
61,904 KB |
testcase_65 | WA | - |
testcase_66 | AC | 867 ms
61,756 KB |
testcase_67 | WA | - |
testcase_68 | AC | 857 ms
62,016 KB |
testcase_69 | WA | - |
testcase_70 | WA | - |
testcase_71 | AC | 864 ms
62,124 KB |
testcase_72 | AC | 855 ms
62,164 KB |
testcase_73 | WA | - |
testcase_74 | WA | - |
testcase_75 | AC | 857 ms
61,988 KB |
testcase_76 | AC | 868 ms
61,900 KB |
testcase_77 | WA | - |
testcase_78 | WA | - |
testcase_79 | WA | - |
testcase_80 | AC | 863 ms
61,984 KB |
testcase_81 | WA | - |
testcase_82 | AC | 959 ms
63,584 KB |
testcase_83 | AC | 953 ms
63,896 KB |
testcase_84 | AC | 960 ms
63,792 KB |
testcase_85 | AC | 954 ms
63,796 KB |
testcase_86 | AC | 945 ms
63,580 KB |
testcase_87 | AC | 960 ms
63,556 KB |
testcase_88 | AC | 958 ms
63,752 KB |
testcase_89 | AC | 950 ms
63,572 KB |
testcase_90 | AC | 961 ms
63,656 KB |
testcase_91 | AC | 958 ms
63,636 KB |
testcase_92 | AC | 863 ms
61,960 KB |
testcase_93 | AC | 858 ms
62,072 KB |
testcase_94 | AC | 958 ms
63,684 KB |
testcase_95 | AC | 968 ms
63,612 KB |
testcase_96 | AC | 953 ms
63,584 KB |
testcase_97 | AC | 969 ms
63,476 KB |
testcase_98 | AC | 960 ms
63,652 KB |
testcase_99 | AC | 953 ms
63,592 KB |
testcase_100 | AC | 871 ms
61,840 KB |
testcase_101 | AC | 976 ms
63,524 KB |
testcase_102 | AC | 962 ms
63,588 KB |
testcase_103 | AC | 968 ms
63,648 KB |
testcase_104 | AC | 958 ms
63,732 KB |
testcase_105 | AC | 963 ms
63,648 KB |
testcase_106 | AC | 970 ms
63,608 KB |
testcase_107 | AC | 982 ms
63,304 KB |
testcase_108 | AC | 967 ms
63,380 KB |
testcase_109 | AC | 965 ms
63,860 KB |
testcase_110 | AC | 976 ms
63,580 KB |
testcase_111 | AC | 967 ms
63,368 KB |
testcase_112 | AC | 969 ms
63,748 KB |
testcase_113 | AC | 988 ms
63,708 KB |
testcase_114 | AC | 975 ms
63,596 KB |
testcase_115 | AC | 970 ms
63,544 KB |
testcase_116 | AC | 973 ms
63,848 KB |
testcase_117 | AC | 974 ms
63,568 KB |
testcase_118 | AC | 969 ms
63,804 KB |
testcase_119 | AC | 965 ms
63,608 KB |
testcase_120 | AC | 953 ms
63,560 KB |
testcase_121 | AC | 964 ms
63,628 KB |
testcase_122 | AC | 966 ms
63,652 KB |
testcase_123 | AC | 986 ms
63,776 KB |
testcase_124 | AC | 982 ms
63,612 KB |
ソースコード
object Main { import java.io.{BufferedReader, InputStream, InputStreamReader} import java.util.StringTokenizer import scala.reflect.ClassTag def main(args: Array[String]): Unit = { val out = new java.io.PrintWriter(System.out) new Main(out, new InputReader(System.in)).solve() out.flush() } private[this] val oj = System.getenv("MY_DEBUG") == null def DEBUG(f: => Unit): Unit = { if (!oj){ f } } def debug(as: Array[Boolean]): Unit = if (!oj){ debug(as.map(x => if(x) "1" else "0").mkString) } def debug(as: Array[Int]): Unit = if (!oj){ debug(as.mkString(" ")) } def debug(as: Array[Long]): Unit =if (!oj){ debug(as.mkString(" ")) } def debugDim(m: Array[Array[Int]]): Unit = if (!oj){ REP(m.length) { i => debug(m(i)) } } def debugDimFlip(m: Array[Array[Long]]): Unit = if (!oj){ REP(m(0).length) { j => REP(m.length) { i => System.err.print(m(i)(j)) System.err.print(" ") } System.err.println() } } def debug(s: => String): Unit = { if (!oj){ System.err.println(s) } } def isDebug[A](debug: => A, online: => A): A = { if (oj) online else debug } class InputReader(val stream: InputStream) { private[this] val reader = new BufferedReader(new InputStreamReader(stream), 32768) private[this] var tokenizer: StringTokenizer = _ private[this] def next(): String = { while (tokenizer == null || !tokenizer.hasMoreTokens) tokenizer = new StringTokenizer(reader.readLine) tokenizer.nextToken } def nextInt(): Int = Integer.parseInt(next()) def nextLong(): Long = java.lang.Long.parseLong(next()) def nextChar(): Char = next().charAt(0) def ni(): Int = nextInt() def nl(): Long = nextLong() def nc(): Char = nextChar() def ns(): String = next() def ns(n: Int): Array[Char] = ns().toCharArray def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset) def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = { val A1, A2 = Array.ofDim[Int](n) REP(n) { i => A1(i) = ni() + offset A2(i) = ni() + offset } (A1, A2) } def nm(n: Int, m: Int): Array[Array[Int]] = { val A = Array.ofDim[Int](n, m) REP(n) { i => REP(m) { j => A(i)(j) = ni() } } A } def nal(n: Int): Array[Long] = map(n)(_ => nl()) def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m)) } def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = { var i = offset val N = n + offset while(i < N) { f(i); i += 1 } } def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = { var i = n - 1 + offset while(i >= offset) { f(i); i -= 1 } } def TO(from: Int, to: Int)(f: Int => Unit): Unit = { REP(to - from + 1, from)(f) } def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = { val res = Array.ofDim[A](n) REP(n)(i => res(i) = f(i + offset)) res } def sumL(as: Array[Int]): Long = { var s = 0L REP(as.length)(i => s += as(i)) s } def cumSum(as: Array[Int]): Array[Long] = { val cum = Array.ofDim[Long](as.length + 1) REP(as.length) { i => cum(i + 1) = cum(i) + as(i) } cum } } object Workspace { import Main._ import java.util.Arrays.sort import scala.collection.mutable import math.{abs, max, min} import mutable.ArrayBuffer } class Main(out: java.io.PrintWriter, sc: Main.InputReader) { import sc._ import Main._ import java.util.Arrays.sort import scala.collection.mutable import math.{abs, max, min} import mutable.ArrayBuffer import Workspace._ import Integer.signum import Math.sqrt // toIntとか+7とかするならvalにしろ final private[this] val MOD = 1000000007 def solve(): Unit = { solve2() match { case None => out.println(-1) case Some(ans) => out.println(ans.length) ans.foreach(a => out.println(f"$a%.15f")) } } def solve2(): Option[Seq[BigDecimal]] = { val a, b, c = ni() val inf = None val none = Some(Seq.empty[BigDecimal]) if (a == 0) { if (b == 0) { if (c == 0) inf // 無限 else none // 解なし } else { Some(Seq(BigDecimal(-c) / b)) } } else { val v = b.toLong*b - 4.toLong*a*c if (v < 0) { none // 虚数 } else if (v == 0) { Some(Seq(-b.toDouble/(2*a))) } else { val n = sqrt(v) debug(f"n:$n%.15f") val x1 = if (b > 0) { (-b.toDouble - n) / (2 * a) } else { (-b.toDouble + n) / (2 * a) } val x2 = c / a / x1 Some(Seq(min(x1, x2), max(x1, x2))) } } } }