結果

問題 No.16 累乗の加算
ユーザー HaarHaar
提出日時 2016-03-07 04:06:41
言語 Haskell
(9.8.2)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 354 bytes
コンパイル時間 4,647 ms
コンパイル使用メモリ 162,908 KB
実行使用メモリ 9,292 KB
最終ジャッジ日時 2023-09-08 11:57:14
合計ジャッジ時間 1,753 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,076 KB
testcase_01 AC 3 ms
7,120 KB
testcase_02 AC 5 ms
9,292 KB
testcase_03 AC 3 ms
7,580 KB
testcase_04 AC 3 ms
7,872 KB
testcase_05 AC 3 ms
7,848 KB
testcase_06 AC 4 ms
8,284 KB
testcase_07 AC 4 ms
8,184 KB
testcase_08 AC 4 ms
8,616 KB
testcase_09 AC 4 ms
8,728 KB
testcase_10 AC 4 ms
8,224 KB
testcase_11 AC 3 ms
7,212 KB
testcase_12 AC 4 ms
8,268 KB
testcase_13 AC 4 ms
7,624 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 #

d = 1000003

decbin 0 = [0]
decbin 1 = [1]
decbin n = (n`mod`2):(decbin (n`div`2))

f x n = product(map(g x)(zipWith(*)(decbin n)[1..]))`mod`d

g x 0 = 1
g x 1 = x
g x n = ((g x (n-1))^2)`mod`d

main=do
    [x,_]<-getLine>>=return.map(read::String->Integer).words
    a<-getLine>>=return.map(read::String->Integer).words
    print$(sum[f x n|n<-a])`mod`d
0