結果

問題 No.320 眠れない夜に
ユーザー はむ吉🐹はむ吉🐹
提出日時 2016-06-27 22:55:17
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 771 bytes
コンパイル時間 3,709 ms
コンパイル使用メモリ 202,880 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-20 04:32:12
合計ジャッジ時間 3,725 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 WA -
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 1 ms
6,944 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 AC 1 ms
6,940 KB
testcase_13 AC 1 ms
6,944 KB
testcase_14 AC 1 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 1 ms
6,944 KB
testcase_18 AC 1 ms
6,940 KB
testcase_19 AC 1 ms
6,940 KB
testcase_20 AC 1 ms
6,940 KB
testcase_21 AC 1 ms
6,940 KB
testcase_22 AC 1 ms
6,944 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 1 ms
6,940 KB
testcase_25 WA -
testcase_26 AC 1 ms
6,944 KB
testcase_27 AC 1 ms
6,944 KB
testcase_28 AC 1 ms
6,940 KB
testcase_29 AC 2 ms
6,940 KB
testcase_30 AC 1 ms
6,940 KB
testcase_31 AC 1 ms
6,940 KB
testcase_32 AC 2 ms
6,940 KB
testcase_33 AC 1 ms
6,940 KB
testcase_34 AC 1 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

ソースコード

diff #

import Control.Applicative ((<$>))
import Data.Int (Int64)
import qualified Data.Vector.Unboxed as V

fibonacci :: (Integral a, V.Unbox a) => a -> a -> [a]
fibonacci a1 a2 = seq a1 $ a1 : fibonacci a2 (a1 + a2)

solve :: (Integral a, V.Unbox a) => a -> a -> Maybe a
solve n m = sol 0 (fromIntegral (n - 3)) d0
    where
        fibs = (V.fromList . take (fromIntegral n)) $ fibonacci 1 1
        d0 = V.last fibs - m
        sol a 0 0 = Just a
        sol _ 0 _ = Nothing
        sol a i d
            | d >= f = sol (a + 1) (i - 1) (d - f)
            | otherwise = sol a (i - 1) d
            where f = fibs V.! i

main :: IO ()
main = do
    [n, m] <- fmap read . words <$> getLine :: IO [Int64]
    print $ case solve n m of
        Just a -> a
        Nothing -> -1
0