Language Test

Submission #1288890

Source codeソースコード

import Control.Applicative ((<$>), (<*>), (<*), (*>), (<$))
import Control.Monad
import Data.List
import Text.Printf

main :: IO ()
main = do
  t <- getl read
  replicateM_ t solve

solve :: IO ()
solve = do
  [a, b, c] <- getl (map read . words) :: IO [Integer]
  if a == 0 then
    if b == 0 then
      if c == 0 then
        putStrLn "3"
      else
        putStrLn "0"
    else do
      let r = (fromIntegral (negate c)) / (fromIntegral b) :: Double
      printf "1 %.10f\n" r
  else do
    let d = b * b - 4 * a * c
    if d < 0 then
      putStrLn "0"
    else
      if d == 0 then do
        let r = (fromIntegral (negate b)) / (2 * (fromIntegral a)) :: Double
        printf "1 %.10f\n" r
      else do
        let r1 = ((fromIntegral (negate b)) + (sqrt (fromIntegral d))) / (2 * (fromIntegral a)) :: Double
            r2 = ((fromIntegral (negate b)) - (sqrt (fromIntegral d))) / (2 * (fromIntegral a)) :: Double
        printf "2 %.10f %.10f\n" (min r1 r2) (max r1 r2)

getl :: (String -> a) -> IO a
getl f = f <$> getLine

Submission

Task問題 H - 一変数方程式
User nameユーザ名 ducktail
Created time投稿日時
Language言語 Haskell (GHC 7.10.3)
Status状態 TLE
Score得点 0
Source lengthソースコード長 1071 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
All 0 / 100 input_01.txt,input_02.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
input_01.txt TLE
input_02.txt AC 1 ms 508 KB