結果
| 問題 |
No.136 Yet Another GCD Problem
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-11-05 09:56:59 |
| 言語 | Haskell (9.10.1) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 906 bytes |
| コンパイル時間 | 430 ms |
| コンパイル使用メモリ | 160,128 KB |
| 最終ジャッジ日時 | 2024-11-14 23:54:02 |
| 合計ジャッジ時間 | 1,073 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
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:13:9: error: [GHC-88464]
Variable not in scope: liftIO :: IO () -> ContT () IO a1
Suggested fix:
Perhaps use one of these:
‘liftM’ (imported from Control.Monad),
‘liftA2’ (imported from Prelude),
‘liftM2’ (imported from Control.Monad)
|
13 | liftIO . print $ n `div` i
| ^^^^^^
Main.hs:15:5: error: [GHC-88464]
Variable not in scope: liftIO :: IO () -> ContT () IO a0
Suggested fix:
Perhaps use one of these:
‘liftM’ (imported from Control.Monad),
‘liftA2’ (imported from Prelude),
‘liftM2’ (imported from Control.Monad)
|
15 | liftIO $ putStrLn "1"
| ^^^^^^
ソースコード
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Control.Monad.Cont
import qualified Data.Vector.Fusion.Stream.Monadic as VFSM
main :: IO ()
main = do
[n, _] <- map (read :: String -> Int) . words <$> getLine
withBreak $ \break -> do
rep 2 n $ \i -> do
when (n `mod` i == 0) $ do
liftIO . print $ n `div` i
break ()
liftIO $ putStrLn "1"
break ()
stream :: Monad m => Int -> Int -> VFSM.Stream m Int
stream !l !r = VFSM.Stream step l
where
step x
| x * x <= r = return $ VFSM.Yield x (x + 1)
| otherwise = return $ VFSM.Done
{-# INLINE [0] step #-}
{-# INLINE [1] stream #-}
rep :: Monad m => Int -> Int -> (Int -> m ()) -> m ()
rep l r = flip VFSM.mapM_ (stream l r)
{-# INLINE rep #-}
withBreak :: ((r -> ContT r IO b) -> ContT r IO r) -> IO r
withBreak = flip runContT pure . callCC
{-# INLINE withBreak #-}