結果

問題 No.16 累乗の加算
ユーザー shikatsusanshikatsusan
提出日時 2016-05-16 02:55:59
言語 Haskell
(9.8.2)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 486 bytes
コンパイル時間 2,581 ms
コンパイル使用メモリ 160,536 KB
実行使用メモリ 8,200 KB
最終ジャッジ日時 2023-09-08 11:59:49
合計ジャッジ時間 1,866 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,124 KB
testcase_01 AC 3 ms
7,152 KB
testcase_02 AC 3 ms
8,200 KB
testcase_03 AC 3 ms
7,496 KB
testcase_04 AC 3 ms
7,520 KB
testcase_05 AC 3 ms
7,596 KB
testcase_06 AC 3 ms
7,884 KB
testcase_07 AC 4 ms
7,788 KB
testcase_08 AC 3 ms
7,928 KB
testcase_09 AC 4 ms
8,172 KB
testcase_10 AC 3 ms
7,764 KB
testcase_11 AC 3 ms
7,264 KB
testcase_12 AC 4 ms
7,820 KB
testcase_13 AC 3 ms
7,360 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 )

Main.hs:14:18: warning: [GHC-47082] [-Woperator-whitespace-ext-conflict]
    The prefix use of a ‘$’ would denote an untyped splice
      were the TemplateHaskell extension enabled.
    Suggested fix: Add whitespace after the ‘$’.
   |
14 |                ) $xsi
   |                  ^
[2 of 2] Linking a.out

ソースコード

diff #

main::IO()
main =do
  xi:_:[] <- fmap (fmap read . words) getLine
  xsi <- fmap (fmap read . words) getLine
  let moda =1000003
      hyou 0 _ = []
      hyou n g =  cal:hyou (n-1) cal
                  where cal = (g * g) `mod` moda 
      xtenkai 0 = []
      xtenkai x = (x `mod` 2 ==1):xtenkai (x `div` 2)
  print . (`mod` moda) . sum . map (\x-> 
               foldl (\acc (a,b) ->if b then acc*a else acc) 1 .
               zip (xi:hyou 31 xi) $ xtenkai x
               ) $xsi
0