結果
問題 | No.1232 2^x = x |
ユーザー | かりあげクン |
提出日時 | 2020-09-23 14:16:12 |
言語 | Haskell (9.8.2) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,762 bytes |
コンパイル時間 | 1,099 ms |
コンパイル使用メモリ | 193,260 KB |
実行使用メモリ | 11,648 KB |
最終ジャッジ日時 | 2023-09-10 07:12:06 |
合計ジャッジ時間 | 2,084 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) Main.hs:27:33: warning: [GHC-68441] [-Wdeprecations] In the use of ‘powModInteger’ (imported from GHC.Integer.GMP.Internals): Deprecated: "Use integerPowMod# instead" | 27 | powModInt a b c = fromInteger $ GMP.powModInteger (fromIntegral a) (fromIntegral b) (fromIntegral c) | ^^^^^^^^^^^^^^^^^ [2 of 2] Linking a.out
ソースコード
{-# LANGUAGE BangPatterns #-} {- base -} import Control.Arrow import Control.Monad import Control.Monad.ST import Data.Bool import Data.Char {- integer-gmp -} import qualified GHC.Integer.GMP.Internals as GMP {- bytestring -} import qualified Data.ByteString.Char8 as BSC8 {- vector -} import qualified Data.Vector as V import qualified Data.Vector.Fusion.Stream.Monadic as VFSM import qualified Data.Vector.Unboxed as VU import qualified Data.Vector.Unboxed.Mutable as VUM main :: IO () main = do n <- parse1 rep n $ \_ -> do p <-parse1 print $ tetrationMod 2 32 (p * (p - 1)) powModInt :: Int -> Int -> Int -> Int powModInt a b c = fromInteger $ GMP.powModInteger (fromIntegral a) (fromIntegral b) (fromIntegral c) {-# INLINE powModInt #-} tetrationMod :: Int -> Int -> Int -> Int tetrationMod a b m | m == 1 = 0 | a == 0 = bool 0 1 (even b) | b == 0 = 1 | b == 1 = a `mod` m | b == 2 = powModInt a b m | otherwise = let phi = m - 1 in powModInt (a `mod` m) ((tetrationMod a (b - 1) phi) + phi) m -- input type Parser a = BSC8.ByteString -> Maybe (a, BSC8.ByteString) parseInt :: Parser Int parseInt = fmap (second BSC8.tail) . BSC8.readInt parse1 :: IO Int parse1 = readLn parseN :: Int -> IO (VU.Vector Int) parseN n = VU.replicateM n parse1 -- rep 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) {-# INLINE rep #-}