結果

問題 No.688 E869120 and Constructing Array 2
ユーザー ducktailducktail
提出日時 2018-05-19 00:00:16
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 521 bytes
コンパイル時間 7,387 ms
コンパイル使用メモリ 167,420 KB
実行使用メモリ 7,108 KB
最終ジャッジ日時 2023-09-21 20:09:37
合計ジャッジ時間 8,549 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,908 KB
testcase_01 AC 3 ms
6,956 KB
testcase_02 AC 2 ms
6,912 KB
testcase_03 WA -
testcase_04 AC 2 ms
6,920 KB
testcase_05 AC 3 ms
6,976 KB
testcase_06 AC 2 ms
6,952 KB
testcase_07 AC 2 ms
7,108 KB
testcase_08 AC 2 ms
7,020 KB
testcase_09 AC 3 ms
7,020 KB
testcase_10 AC 2 ms
6,956 KB
testcase_11 AC 2 ms
6,908 KB
testcase_12 AC 3 ms
7,100 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import Control.Applicative ((<$>))
import Data.List (intercalate)

main :: IO ()
main = solve <$> readLn >>= mapM_ putStrLn

solve :: Int -> [String]
solve 0 = ["1", "0"]
solve 1 = ["2", "1 1"]
solve k = let l = g 0 k in [show . length $ l, intercalate " " . map show $ l]
  where f x = let y = ceiling . sqrt . (* 2) . fromIntegral $ x in if 2 * x == y * (y-1) then Just y else Nothing
        g z x = case f x of
                 Just i -> replicate z 0 ++ replicate i 1
                 Nothing -> g (z+1) (x `div` 2)
0