結果

問題 No.523 LED
ユーザー こまるこまる
提出日時 2020-11-04 21:54:38
言語 Haskell
(9.8.2)
結果
AC  
実行時間 672 ms / 2,000 ms
コード長 731 bytes
コンパイル時間 3,286 ms
コンパイル使用メモリ 159,676 KB
実行使用メモリ 11,080 KB
最終ジャッジ日時 2023-09-29 16:20:14
合計ジャッジ時間 8,445 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,872 KB
testcase_01 AC 3 ms
7,004 KB
testcase_02 AC 12 ms
8,588 KB
testcase_03 AC 2 ms
6,852 KB
testcase_04 AC 2 ms
6,900 KB
testcase_05 AC 662 ms
11,080 KB
testcase_06 AC 2 ms
6,908 KB
testcase_07 AC 2 ms
6,916 KB
testcase_08 AC 2 ms
6,896 KB
testcase_09 AC 12 ms
7,912 KB
testcase_10 AC 2 ms
6,856 KB
testcase_11 AC 3 ms
6,908 KB
testcase_12 AC 3 ms
6,888 KB
testcase_13 AC 133 ms
10,928 KB
testcase_14 AC 3 ms
6,908 KB
testcase_15 AC 3 ms
7,012 KB
testcase_16 AC 3 ms
6,916 KB
testcase_17 AC 3 ms
7,032 KB
testcase_18 AC 672 ms
10,992 KB
testcase_19 AC 242 ms
10,936 KB
testcase_20 AC 212 ms
10,968 KB
testcase_21 AC 502 ms
11,036 KB
testcase_22 AC 562 ms
10,888 KB
testcase_23 AC 562 ms
10,888 KB
testcase_24 AC 22 ms
9,676 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 #

{-# LANGUAGE BangPatterns #-}

import           Data.IORef
import qualified Data.Vector.Fusion.Stream.Monadic as VFSM

modulo :: Int
modulo = 1000000007

main :: IO ()
main = do
  n <- readLn :: IO Int
  ret <- newIORef (1 :: Int)
  rev n $ \i -> modifyIORef' ret (\x -> (x * ((2 * i - 1) `mod` modulo * i `mod` modulo) `mod` modulo) `mod` modulo)
  print =<< readIORef ret

streamR :: Monad m => Int -> Int -> VFSM.Stream m Int
streamR !l !r = VFSM.Stream step r
  where
    step x
      | x >= l    = return $ VFSM.Yield x (x - 1)
      | otherwise = return $ VFSM.Done
    {-# INLINE [0] step #-}
{-# INLINE [1] streamR #-}

rev :: Monad m => Int -> (Int -> m ()) -> m ()
rev n = flip VFSM.mapM_ (streamR 1 n)
{-# INLINE rev #-}
0