結果
問題 | No.41 貯金箱の溜息(EASY) |
ユーザー | こまる |
提出日時 | 2020-10-14 12:34:50 |
言語 | Haskell (9.8.2) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,527 bytes |
コンパイル時間 | 6,695 ms |
コンパイル使用メモリ | 225,408 KB |
実行使用メモリ | 8,832 KB |
最終ジャッジ日時 | 2024-07-20 19:04:27 |
合計ジャッジ時間 | 7,448 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
コンパイルメッセージ
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
ソースコード
{-# LANGUAGE BangPatterns #-} import Control.Monad import Control.Monad.ST import Control.Monad.State.Strict import Data.Char import qualified Data.ByteString.Char8 as BSC8 import qualified Data.Vector.Fusion.Stream.Monadic as VFSM import qualified Data.Vector.Unboxed as VU import qualified Data.Vector.Unboxed.Mutable as VUM stream :: Monad m => Int -> Int -> VFSM.Stream m Int stream !l !r = VFSM.Stream step l where step x | x < r = return $ VFSM.Yield x (x + 1) | otherwise = return $ VFSM.Done {-# INLINE [0] step #-} {-# INLINE [1] stream #-} rep :: Monad m => Int -> (Int -> m ()) -> m () rep n = flip VFSM.mapM_ (stream 0 (n + 1)) {-# INLINE rep #-} rep' :: Monad m => Int -> (Int -> m ()) -> m () rep' n = flip VFSM.mapM_ (stream 0 n) {-# INLINE rep' #-} rep1 :: Monad m => Int -> (Int -> m ()) -> m () rep1 n = flip VFSM.mapM_ (stream 1 (n + 1)) {-# INLINE rep1 #-} rep1' :: Monad m => Int -> (Int -> m ()) -> m () rep1' n = flip VFSM.mapM_ (stream 1 (n + 1)) {-# INLINE rep1' #-} main :: IO () main = do n <- readLn :: IO Int dp <- VUM.replicate 100100 (1 :: Int) VUM.unsafeWrite dp 0 (0 :: Int) rep1 9 $ \i -> rep 100000 $ \j -> do when (i + j <= 100000) $ do item1 <- VUM.unsafeRead dp (j + i) item2 <- VUM.unsafeRead dp j VUM.unsafeWrite dp (j + i) (mod (item1 + item2) 1000000009) rep' n $ \_ -> do m <- readLn :: IO Int print =<< VUM.unsafeRead dp (m `div` 111111)