結果

問題 No.278 連続する整数の和(2)
ユーザー はむ吉🐹はむ吉🐹
提出日時 2015-11-17 16:00:29
言語 Haskell
(9.8.2)
結果
AC  
実行時間 82 ms / 2,000 ms
コード長 333 bytes
コンパイル時間 5,745 ms
コンパイル使用メモリ 157,512 KB
実行使用メモリ 11,252 KB
最終ジャッジ日時 2023-08-24 22:46:14
合計ジャッジ時間 4,336 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,964 KB
testcase_01 AC 2 ms
7,100 KB
testcase_02 AC 72 ms
11,168 KB
testcase_03 AC 3 ms
6,936 KB
testcase_04 AC 2 ms
7,008 KB
testcase_05 AC 4 ms
8,784 KB
testcase_06 AC 6 ms
9,804 KB
testcase_07 AC 12 ms
10,044 KB
testcase_08 AC 62 ms
11,252 KB
testcase_09 AC 62 ms
11,200 KB
testcase_10 AC 82 ms
11,252 KB
testcase_11 AC 62 ms
11,116 KB
testcase_12 AC 2 ms
7,020 KB
testcase_13 AC 52 ms
11,152 KB
testcase_14 AC 42 ms
11,128 KB
testcase_15 AC 52 ms
11,136 KB
testcase_16 AC 42 ms
11,228 KB
testcase_17 AC 62 ms
11,192 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 #

import           Data.List (nub)

divisors :: Integral a => a -> [a]
divisors 1 = [1]
divisors n = (1 :) $ (n :) $ nub $ concat [[x, d] |
    x <- [2 .. l], let (d, m) = divMod n x, m == 0]
    where l = floor $ sqrt $ fromIntegral n

main :: IO ()
main = print . sum .
    divisors . (\n -> if odd n then n else div n 2) =<< readLn
0