結果

問題 No.604 誕生日のお小遣い
ユーザー kuwakuwa
提出日時 2017-12-04 01:56:34
言語 Haskell
(9.8.2)
結果
AC  
実行時間 3 ms / 1,000 ms
コード長 1,064 bytes
コンパイル時間 4,921 ms
コンパイル使用メモリ 160,292 KB
実行使用メモリ 7,324 KB
最終ジャッジ日時 2023-08-14 01:23:13
合計ジャッジ時間 6,245 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,284 KB
testcase_01 AC 3 ms
7,312 KB
testcase_02 AC 3 ms
7,232 KB
testcase_03 AC 2 ms
7,248 KB
testcase_04 AC 3 ms
7,276 KB
testcase_05 AC 3 ms
7,280 KB
testcase_06 AC 3 ms
7,220 KB
testcase_07 AC 3 ms
7,284 KB
testcase_08 AC 2 ms
7,176 KB
testcase_09 AC 2 ms
7,228 KB
testcase_10 AC 3 ms
7,168 KB
testcase_11 AC 2 ms
7,172 KB
testcase_12 AC 2 ms
7,220 KB
testcase_13 AC 2 ms
7,276 KB
testcase_14 AC 2 ms
7,268 KB
testcase_15 AC 2 ms
7,176 KB
testcase_16 AC 2 ms
7,156 KB
testcase_17 AC 2 ms
7,164 KB
testcase_18 AC 3 ms
7,300 KB
testcase_19 AC 2 ms
7,248 KB
testcase_20 AC 2 ms
7,312 KB
testcase_21 AC 3 ms
7,284 KB
testcase_22 AC 3 ms
7,324 KB
testcase_23 AC 2 ms
7,240 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

module Main where
import Control.Monad
import Control.Applicative
import Data.Maybe
import Data.List
import qualified Text.Printf
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString as BC

import Debug.Trace

------------------------------------------

lowerBound :: (Integer -> Bool) -> Integer -> Integer -> Integer
lowerBound pred l r 
  | l + 1 >= r = r
  | otherwise =
    let m = (l + r) `div` 2 in 
      if pred m then lowerBound pred l m else lowerBound pred m r

main :: IO ()
main = do
  [a, b, c] <- map fromIntegral <$> readInts
  let f x = x + (x `div` a) * (b - 1)
  print $ lowerBound ((>= c) . f) 0 (10^18)
------------------------------------------

{- Int input -}

parseInt :: BC.ByteString -> Int
parseInt = fst . fromJust . BC.readInt

parseInts :: BC.ByteString -> [Int]
parseInts = map parseInt <$> BC.words

readInt :: IO Int
readInt = parseInt <$> BC.getLine

readInts :: IO [Int]
readInts = parseInts <$> BC.getLine

{- Double Formatting -}

doubleFmt :: Double -> String
doubleFmt = Text.Printf.printf "%.12f"
0