結果

問題 No.784 「,(カンマ)」
ユーザー nao22bnao22b
提出日時 2019-04-13 17:19:22
言語 Elixir
(1.16.2)
結果
AC  
実行時間 632 ms / 2,000 ms
コード長 456 bytes
コンパイル時間 1,045 ms
コンパイル使用メモリ 55,764 KB
実行使用メモリ 50,088 KB
最終ジャッジ日時 2023-08-29 23:17:53
合計ジャッジ時間 10,828 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 614 ms
49,732 KB
testcase_01 AC 612 ms
49,296 KB
testcase_02 AC 609 ms
49,144 KB
testcase_03 AC 621 ms
49,984 KB
testcase_04 AC 621 ms
49,140 KB
testcase_05 AC 623 ms
49,208 KB
testcase_06 AC 632 ms
49,156 KB
testcase_07 AC 624 ms
49,304 KB
testcase_08 AC 623 ms
49,224 KB
testcase_09 AC 623 ms
49,660 KB
testcase_10 AC 623 ms
49,228 KB
testcase_11 AC 624 ms
49,248 KB
testcase_12 AC 629 ms
50,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

defmodule Main do
    def solve("", acc), do: acc

    def solve(s, acc) do
        l = String.at(s, -1)
        ss = String.slice(s, 0..-2)
        ac = append(l, acc, String.length(acc))
        solve(ss, ac)
    end

    def append(l, acc, len) when rem(len, 4) == 3 do
        l <> "," <> acc
    end
    def append(l, acc, _) do
        l <> acc
    end

    def main do
        s = IO.gets("") |> String.trim
        IO.puts solve(s, "")
    end
end
0