結果
問題 | No.16 累乗の加算 |
ユーザー | こまる |
提出日時 | 2020-10-19 21:40:46 |
言語 | Haskell (9.8.2) |
結果 |
WA
|
実行時間 | - |
コード長 | 782 bytes |
コンパイル時間 | 7,759 ms |
コンパイル使用メモリ | 198,968 KB |
実行使用メモリ | 8,032 KB |
最終ジャッジ日時 | 2023-09-28 13:28:38 |
合計ジャッジ時間 | 8,830 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
7,860 KB |
testcase_01 | AC | 3 ms
7,864 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 2 ms
7,948 KB |
testcase_12 | WA | - |
testcase_13 | AC | 3 ms
7,576 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 ) Main.hs:15:25: warning: [GHC-68441] [-Wdeprecations] In the use of ‘powModInteger’ (imported from GHC.Integer.GMP.Internals): Deprecated: "Use integerPowMod# instead" | 15 | powModInt a n mo = fI $ GMP.powModInteger (fi a) (fi n) (fi mo) | ^^^^^^^^^^^^^^^^^ [2 of 2] Linking a.out
ソースコード
import Control.Arrow import qualified Data.ByteString.Char8 as BSC8 import qualified Data.Vector.Unboxed as VU import qualified GHC.Integer.GMP.Internals as GMP fi :: Int -> Integer fi = fromIntegral {-# INLINE fi #-} fI :: Integer -> Int fI = fromInteger {-# INLINE fI #-} powModInt :: Int -> Int -> Int -> Int powModInt a n mo = fI $ GMP.powModInteger (fi a) (fi n) (fi mo) type Parser a = BSC8.ByteString -> Maybe (a, BSC8.ByteString) parseInt :: Parser Int parseInt = fmap (second BSC8.tail) . BSC8.readInt parseM :: Int -> IO (VU.Vector Int) parseM m = VU.unfoldrN m parseInt <$> BSC8.getLine main :: IO () main = do [x, m] <- map (read :: String -> Int) . words <$> getLine an <- parseM m print $ VU.sum $ VU.map (\y -> powModInt x y 1000003) an