結果

問題 No.810 割った余りの個数
ユーザー nao22bnao22b
提出日時 2019-04-12 21:36:28
言語 Elixir
(1.16.2)
結果
AC  
実行時間 656 ms / 2,000 ms
コード長 460 bytes
コンパイル時間 1,033 ms
コンパイル使用メモリ 54,680 KB
実行使用メモリ 50,176 KB
最終ジャッジ日時 2023-08-29 23:15:11
合計ジャッジ時間 22,470 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 626 ms
49,956 KB
testcase_01 AC 635 ms
49,152 KB
testcase_02 AC 636 ms
49,220 KB
testcase_03 AC 631 ms
49,228 KB
testcase_04 AC 627 ms
49,088 KB
testcase_05 AC 623 ms
49,340 KB
testcase_06 AC 627 ms
49,780 KB
testcase_07 AC 628 ms
49,288 KB
testcase_08 AC 613 ms
49,792 KB
testcase_09 AC 630 ms
49,132 KB
testcase_10 AC 629 ms
49,184 KB
testcase_11 AC 638 ms
49,104 KB
testcase_12 AC 637 ms
49,144 KB
testcase_13 AC 637 ms
49,124 KB
testcase_14 AC 637 ms
49,144 KB
testcase_15 AC 631 ms
49,860 KB
testcase_16 AC 625 ms
49,284 KB
testcase_17 AC 625 ms
50,132 KB
testcase_18 AC 615 ms
49,928 KB
testcase_19 AC 656 ms
49,264 KB
testcase_20 AC 629 ms
49,224 KB
testcase_21 AC 630 ms
49,188 KB
testcase_22 AC 633 ms
49,860 KB
testcase_23 AC 634 ms
49,732 KB
testcase_24 AC 625 ms
49,996 KB
testcase_25 AC 625 ms
49,056 KB
testcase_26 AC 626 ms
49,292 KB
testcase_27 AC 628 ms
49,264 KB
testcase_28 AC 635 ms
50,176 KB
testcase_29 AC 632 ms
47,952 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

defmodule Main do
    def solve(l, l, _) do
        1
    end
    def solve(l, r, m) when (r - l) >= m do
        m
    end
    def solve(l, r, m) do
        a = rem(l, m)
        b = rem(r, m)
        cond do
            b >= a -> (b - a + 1)
            true -> (m - a) + b + 1
        end
    end

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