結果
問題 | No.64 XORフィボナッチ数列 |
ユーザー |
![]() |
提出日時 | 2014-11-19 01:28:23 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 369 bytes |
コンパイル時間 | 6,441 ms |
コンパイル使用メモリ | 175,744 KB |
実行使用メモリ | 5,888 KB |
最終ジャッジ日時 | 2025-01-02 19:09:57 |
合計ジャッジ時間 | 7,332 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 11 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.10.1/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) Main.hs:8:36: warning: [GHC-63394] [-Wx-partial] In the use of ‘tail’ (imported from Prelude, but defined in GHC.Internal.List): "This is a partial function, it throws an error on empty lists. Replace it with 'drop' 1, or use pattern matching or 'GHC.Internal.Data.List.uncons' instead. Consider refactoring to use "Data.List.NonEmpty"." | 8 | fib a b = a : b : zipWith' xor xs (tail xs) where | ^^^^ [2 of 2] Linking a.out
ソースコード
import Data.Bits zipWith' :: (a -> b -> c) -> [a] -> [b] -> [c] zipWith' f (x:xs) (y:ys) = let z = f x y in z `seq` z : zipWith' f xs ys zipWith' _ _ _ = [] fib :: Int -> Int -> [Int] fib a b = a : b : zipWith' xor xs (tail xs) where xs = fib a b main = do [a, b, n] <- fmap (map read . words) getLine print $ fib a b !! (n `mod` 3)