結果
問題 |
No.415 ぴょん
|
ユーザー |
|
提出日時 | 2017-04-20 16:29:10 |
言語 | Haskell (9.10.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 718 bytes |
コンパイル時間 | 2,250 ms |
コンパイル使用メモリ | 170,496 KB |
実行使用メモリ | 620,572 KB |
最終ジャッジ日時 | 2024-07-19 21:04:41 |
合計ジャッジ時間 | 4,893 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | WA * 2 MLE * 1 OLE * 1 -- * 23 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) Main.hs:15:39: warning: [GHC-63394] [-Wx-partial] In the use of ‘tail’ (imported from Prelude, but defined in GHC.List): "This is a partial function, it throws an error on empty lists. Replace it with drop 1, or use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty." | 15 | hasira' | m == 0 = 0 : tail hasira | ^^^^ Main.hs:23:13: warning: [GHC-63394] [-Wx-partial] In the use of ‘head’ (imported from Prelude, but defined in GHC.List): "This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty." | 23 | n = head nk | ^^^^ [2 of 2] Linking a.out
ソースコード
--pyon -- n : 足場の数 -- k : 飛ぶ幅 import Control.Monad import Debug.Trace pyon :: Int -> Int -> [Int] -> Int -> Int pyon n k hasira cnt | isEnd == True = 0 | otherwise = 1 + pyon n k hasira' m where m = (cnt + k) `mod` n isEnd = (hasira !! m) == 0 hasira' | m == 0 = 0 : tail hasira | m == n - 1 = (take (n - 1) hasira) ++ [0] | otherwise = (take m hasira) ++ [0] ++ (drop (m+1) hasira) main = do nk <- map (read :: String -> Int) . words <$> getLine let hasira = [0] ++ take (n - 1) [1,1..] n = head nk k = last nk print n print k print hasira print $ pyon n k hasira 0