結果
| 問題 | No.550 夏休みの思い出(1) |
| コンテスト | |
| ユーザー |
tottoripaper
|
| 提出日時 | 2017-07-28 23:35:18 |
| 言語 | Haskell (9.10.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,225 bytes |
| 記録 | |
| コンパイル時間 | 4,604 ms |
| コンパイル使用メモリ | 169,660 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-10 05:28:06 |
| 合計ジャッジ時間 | 6,178 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 RE * 31 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
import Data.List (sort)
readMany :: (Read a) => IO [a]
readMany = fmap (map read . words) getLine
solve :: (Integer -> Integer) -> Integer -> Integer -> Integer
solve f l r
| l == r = 10^9
| abs (r - l) == 1 = l
| f mid > 0 = solve f l mid
| otherwise = solve f mid r
where
mid = (l + r) `div` 2
isValid f x = f x == 0
main = do
[a, b, c] <- readMany
let x0 = solve f (-10^12) (10^12)
x1 = solve f (-10^12) x0
x2 = solve f (x0 + 1) (10^12)
f x = x^3 + a * x^2 + b * x + c
l = sort $ case (isValid f x1, isValid f x2, x1 /= x2) of
(True, True, True) -> [x0, x1, x2]
(True, False, _) -> let [x0', x1'] = sort [x0, x1]
x2' = solve f (x1' - 1) x0'
x3' = solve f (-10^12) x0'
in [x0', x1', if isValid f x2' then x2' else x3']
(False, True, _) -> let [x0', x1'] = sort [x0, x2]
x2' = solve f (x1' - 1) x0'
x3' = solve f (x1' + 1) (10^12)
in [x0', x1', if isValid f x2' then x2' else x3']
otherwise -> undefined
-- print [x0, x1, x2]
putStrLn $ unwords $ map show l
tottoripaper