結果

問題 No.480 合計
ユーザー yukiccoyukicco
提出日時 2018-11-16 22:28:56
言語 Elixir
(1.16.2)
結果
AC  
実行時間 637 ms / 2,000 ms
コード長 623 bytes
コンパイル時間 1,062 ms
コンパイル使用メモリ 54,804 KB
実行使用メモリ 50,052 KB
最終ジャッジ日時 2023-08-29 23:01:40
合計ジャッジ時間 16,410 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 633 ms
49,348 KB
testcase_01 AC 628 ms
49,288 KB
testcase_02 AC 624 ms
49,392 KB
testcase_03 AC 617 ms
49,852 KB
testcase_04 AC 631 ms
49,840 KB
testcase_05 AC 621 ms
49,828 KB
testcase_06 AC 625 ms
49,368 KB
testcase_07 AC 625 ms
49,268 KB
testcase_08 AC 625 ms
49,304 KB
testcase_09 AC 635 ms
49,744 KB
testcase_10 AC 632 ms
49,252 KB
testcase_11 AC 628 ms
49,804 KB
testcase_12 AC 632 ms
49,328 KB
testcase_13 AC 622 ms
49,284 KB
testcase_14 AC 627 ms
49,168 KB
testcase_15 AC 626 ms
49,860 KB
testcase_16 AC 629 ms
49,312 KB
testcase_17 AC 627 ms
49,652 KB
testcase_18 AC 631 ms
49,132 KB
testcase_19 AC 631 ms
49,708 KB
testcase_20 AC 625 ms
50,052 KB
testcase_21 AC 637 ms
49,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

defmodule Main do
    def getsAll(device \\ :stdio, prompt), do: getsAll(device, prompt, "")
    defp getsAll(device, prompt, input) do
        x = IO.gets(device, prompt)
        case x do
            {:error, _} -> x
            :eof -> input
            _ -> getsAll(device, prompt, input <> x)
        end
    end
    def sum(n), do: sum(n, 1)
    defp sum(n, acc) do
        case n do
            1 -> acc
            _ -> sum(n - 1, acc + n)
        end
    end
    def main do

        inputs = getsAll(nil) |> String.split

        n = inputs |> Enum.at(0) |> String.to_integer

        IO.puts sum(n)

    end
end
0