• + 2 comments

    Haskell Solution

    If you just gave up with Haskell, here is my solution. But, I think my solution is not really great.

    fib :: Integer -> Integer
    fib n = fibz n [0, 0, 1]
        where
        fibz :: Integer -> [Integer] -> Integer
        fibz 0 (_:y:_)     = y
        fibz n (x:y:z:(_)) = fibz (n - 1) [y, z, y + z]
    
    main :: IO ()
    main = do
        n <- readLn :: IO Int
        l <- fmap (take n . lines) getContents :: IO [String]
        
        let x = map read l :: [Integer]
        
        output x
    
    output :: [Integer] -> IO ()
    output []     = return ()
    output (x:xs) = print ((fib x) `mod` 100000007) >> output xs