結果

問題 No.40 多項式の割り算
ユーザー anta
提出日時 2014-10-15 00:00:24
言語 Haskell
(9.10.1)
結果
AC  
実行時間 30 ms / 5,000 ms
コード長 477 bytes
コンパイル時間 2,214 ms
コンパイル使用メモリ 175,616 KB
実行使用メモリ 12,032 KB
最終ジャッジ日時 2024-12-30 09:09:16
合計ジャッジ時間 3,600 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 Data.List
import Control.Applicative
import Control.Monad

main = do
    _ <- getLine
    bs <- map read. words <$> getLine
    let ans = solve bs
    print (length ans - 1)
    putStrLn. unwords. map show$ ans

solve bs = reverse. canonicalize. rec. reverse$ bs
    where
        rec (x3:x2:x1:x0:xs) = rec (x2:(x1+x3):x0:xs)
        rec xs = xs
        canonicalize xs
            | all (0==) xs = [0]
            | otherwise    = dropWhile (==0) xs
0