結果

問題 No.278 連続する整数の和(2)
ユーザー aimyaimy
提出日時 2017-06-17 09:54:29
言語 Haskell
(9.2.2)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 249 bytes
コンパイル時間 1,118 ms
使用メモリ 8,652 KB
最終ジャッジ日時 2023-01-12 16:08:09
合計ジャッジ時間 2,368 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 2 ms
4,240 KB
testcase_01 AC 2 ms
4,168 KB
testcase_02 AC 60 ms
8,492 KB
testcase_03 AC 2 ms
4,304 KB
testcase_04 AC 2 ms
4,412 KB
testcase_05 AC 3 ms
5,116 KB
testcase_06 AC 5 ms
5,904 KB
testcase_07 AC 5 ms
5,928 KB
testcase_08 AC 56 ms
8,432 KB
testcase_09 AC 56 ms
8,432 KB
testcase_10 AC 72 ms
8,416 KB
testcase_11 AC 55 ms
8,600 KB
testcase_12 AC 2 ms
4,164 KB
testcase_13 AC 47 ms
8,444 KB
testcase_14 AC 39 ms
8,432 KB
testcase_15 AC 42 ms
8,468 KB
testcase_16 AC 34 ms
8,440 KB
testcase_17 AC 58 ms
8,652 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 #

main = readLn >>= print . xsum

xsum :: Integer -> Integer
xsum n = foldr dsum 0 [1 .. floor (sqrt (fromIntegral d))]
 where
  dsum x acc = let (q,r) = divMod d x in if r/=0 then acc else if x==q then acc+x else acc+x+q
  d = gcd n (div (n*(n-1)) 2)
0