結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,120 KB
testcase_01 AC 2 ms
7,060 KB
testcase_02 AC 5 ms
9,152 KB
testcase_03 AC 3 ms
7,752 KB
testcase_04 AC 3 ms
7,688 KB
testcase_05 AC 4 ms
7,848 KB
testcase_06 AC 4 ms
8,344 KB
testcase_07 AC 4 ms
8,088 KB
testcase_08 AC 4 ms
8,584 KB
testcase_09 AC 5 ms
8,704 KB
testcase_10 AC 5 ms
8,232 KB
testcase_11 AC 3 ms
7,208 KB
testcase_12 AC 4 ms
8,268 KB
testcase_13 AC 3 ms
7,640 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