結果

問題 No.16 累乗の加算
ユーザー aimyaimy
提出日時 2017-04-18 13:23:22
言語 Haskell
(9.8.2)
結果
TLE  
実行時間 -
コード長 290 bytes
コンパイル時間 1,251 ms
コンパイル使用メモリ 159,224 KB
実行使用メモリ 7,276 KB
最終ジャッジ日時 2023-09-26 13:14:38
合計ジャッジ時間 8,403 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,128 KB
testcase_01 AC 3 ms
7,276 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/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