結果

問題 No.16 累乗の加算
ユーザー trineutrontrineutron
提出日時 2019-07-23 21:35:23
言語 Haskell
(9.8.2)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 288 bytes
コンパイル時間 1,976 ms
コンパイル使用メモリ 159,972 KB
実行使用メモリ 8,004 KB
最終ジャッジ日時 2023-09-08 16:36:03
合計ジャッジ時間 3,131 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,088 KB
testcase_01 AC 3 ms
7,108 KB
testcase_02 AC 4 ms
8,004 KB
testcase_03 AC 3 ms
7,340 KB
testcase_04 AC 3 ms
7,416 KB
testcase_05 AC 3 ms
7,448 KB
testcase_06 AC 4 ms
7,696 KB
testcase_07 AC 3 ms
7,584 KB
testcase_08 AC 4 ms
7,900 KB
testcase_09 AC 4 ms
7,964 KB
testcase_10 AC 3 ms
7,680 KB
testcase_11 AC 3 ms
7,120 KB
testcase_12 AC 3 ms
7,628 KB
testcase_13 AC 3 ms
7,492 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 )
[2 of 2] Linking a.out

ソースコード

diff #

pow _ 0 = 1
pow x i
    | even i = pow (x * x `mod` 1000003) (i `div` 2)
    | otherwise = pow (x * x `mod` 1000003) (i `div` 2) * x `mod` 1000003

main = do
    [x, n] <- map read . words <$> getLine
    a <- map read . words <$> getLine
    print . (`mod` 1000003) . sum $ map (pow x) a
0