結果
問題 | No.16 累乗の加算 |
ユーザー | こまる |
提出日時 | 2020-10-19 21:43:20 |
言語 | Haskell (9.8.2) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 822 bytes |
コンパイル時間 | 8,367 ms |
コンパイル使用メモリ | 195,328 KB |
実行使用メモリ | 7,968 KB |
最終ジャッジ日時 | 2023-09-28 13:29:41 |
合計ジャッジ時間 | 3,064 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
7,900 KB |
testcase_01 | AC | 3 ms
7,800 KB |
testcase_02 | AC | 3 ms
7,812 KB |
testcase_03 | AC | 3 ms
7,780 KB |
testcase_04 | AC | 3 ms
7,768 KB |
testcase_05 | AC | 3 ms
7,912 KB |
testcase_06 | AC | 3 ms
7,968 KB |
testcase_07 | AC | 3 ms
7,824 KB |
testcase_08 | AC | 3 ms
7,736 KB |
testcase_09 | AC | 3 ms
7,852 KB |
testcase_10 | AC | 2 ms
7,796 KB |
testcase_11 | AC | 3 ms
7,756 KB |
testcase_12 | AC | 3 ms
7,772 KB |
testcase_13 | AC | 3 ms
7,444 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.foldl1' (\acc x -> (acc + x) `mod` 1000003) $ VU.map (\y -> powModInt x y 1000003) an