結果

問題 No.278 連続する整数の和(2)
ユーザー はむ吉🐹はむ吉🐹
提出日時 2015-11-17 16:00:29
言語 Haskell
(9.2.2)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 333 bytes
コンパイル時間 2,417 ms
使用メモリ 8,544 KB
最終ジャッジ日時 2023-01-12 15:59:23
合計ジャッジ時間 4,236 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
4,116 KB
testcase_01 AC 2 ms
4,136 KB
testcase_02 AC 72 ms
8,276 KB
testcase_03 AC 2 ms
4,400 KB
testcase_04 AC 2 ms
4,200 KB
testcase_05 AC 4 ms
5,644 KB
testcase_06 AC 5 ms
6,640 KB
testcase_07 AC 9 ms
6,724 KB
testcase_08 AC 68 ms
8,344 KB
testcase_09 AC 67 ms
8,308 KB
testcase_10 AC 86 ms
8,336 KB
testcase_11 AC 66 ms
8,380 KB
testcase_12 AC 2 ms
4,432 KB
testcase_13 AC 56 ms
8,296 KB
testcase_14 AC 45 ms
8,340 KB
testcase_15 AC 49 ms
8,328 KB
testcase_16 AC 39 ms
8,288 KB
testcase_17 AC 69 ms
8,544 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.2.2/environments/default
[1 of 1] Compiling Main             ( Main.hs, Main.o )
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