結果

問題 No.16 累乗の加算
ユーザー aimy
提出日時 2017-04-18 13:23:22
言語 Haskell
(9.10.1)
結果
TLE  
実行時間 -
コード長 290 bytes
コンパイル時間 1,853 ms
コンパイル使用メモリ 174,336 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-07-19 07:37:03
合計ジャッジ時間 7,952 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 2 TLE * 1 -- * 11
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

main = do
 (x:_:exps) <- map read . words <$> getContents
 print (power x exps)

power :: Integer -> [Integer] -> Integer
power x exps = sum (map (pow x) exps) `mod` 1000003
 where
  pow x n
   | n == 0 = 1
   | n == 1 = x
   | odd n = x * pow x (n-1)
   | otherwise = (pow x (div n 2)) ^ 2
0