結果

問題 No.799 赤黒かーどげぇむ
ユーザー nao22b
提出日時 2019-04-13 10:33:13
言語 Elixir
(1.18.1)
結果
AC  
実行時間 532 ms / 2,000 ms
コード長 586 bytes
コンパイル時間 1,032 ms
コンパイル使用メモリ 62,904 KB
実行使用メモリ 55,176 KB
最終ジャッジ日時 2024-12-31 02:45:28
合計ジャッジ時間 12,729 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
    warning: reserved alias "True" expands to the atom :"Elixir.True". Perhaps you meant to write "true" instead?
    │
  6 │             True -> count_num(i + 1, a, b, c, d)
    │             ~
    │
    └─ Main.exs:6:13: Main.count_num/5

ソースコード

diff #

defmodule Main do
    def count_num(i, a, b, c, d) do
        cond do
            i > b -> 0 
            i >= c && i <= d -> 1 + count_num(i + 1, a, b, c, d)
            True -> count_num(i + 1, a, b, c, d)
        end
    end
    
    def same_number_count(a, b, c, d) do
        count_num(a, a, b, c, d)
    end


    def solve(a, b, c, d) do
        (b - a + 1) * (d - c + 1) - same_number_count(a, b, c, d)
    end

    def main do
        [a, b, c, d] = IO.gets("") |> String.trim |> String.split |> Enum.map(&String.to_integer/1)
        solve(a, b, c, d) |> IO.puts
    end
end
0