提出 #17078978


ソースコード 拡げる

defmodule Main do
  def main do
    IO.read(:line)
    |> String.trim()
    |> String.to_integer()
    |> solve()
    |> IO.puts()
  end

  @doc ~S"""
  https://atcoder.jp/contests/abc174/tasks/abc174_c

  ## Examples

      iex> AtCorder174C.solve(101)
      4
      iex> AtCorder174C.solve(2)
      -1
      iex> AtCorder174C.solve(999983)
      999982


  """
  def solve(k) do
    1..k
    |> Enum.reduce_while({0, -1}, fn i, {a, _result} ->
      a = a * 10 + 7
      rem = rem(a, k)
      if rem == 0, do: {:halt, {rem, i}}, else: {:cont, {rem, -1}}
    end)
    |> elem(1)
  end
end

提出情報

提出日時
問題 C - Repsept
ユーザ awesomey
言語 Elixir (1.10.2)
得点 300
コード長 621 Byte
結果 AC
実行時間 471 ms
メモリ 30856 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 3
AC × 27
セット名 テストケース
Sample sample_01.txt, sample_02.txt, sample_03.txt
All hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, hand_11.txt, hand_12.txt, hand_13.txt, hand_14.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, sample_01.txt, sample_02.txt, sample_03.txt
ケース名 結果 実行時間 メモリ
hand_01.txt AC 413 ms 30604 KiB
hand_02.txt AC 471 ms 30596 KiB
hand_03.txt AC 400 ms 30532 KiB
hand_04.txt AC 404 ms 30708 KiB
hand_05.txt AC 459 ms 30624 KiB
hand_06.txt AC 467 ms 30668 KiB
hand_07.txt AC 404 ms 30740 KiB
hand_08.txt AC 422 ms 30756 KiB
hand_09.txt AC 438 ms 30804 KiB
hand_10.txt AC 388 ms 30716 KiB
hand_11.txt AC 408 ms 30744 KiB
hand_12.txt AC 400 ms 30576 KiB
hand_13.txt AC 413 ms 30848 KiB
hand_14.txt AC 397 ms 30536 KiB
random_01.txt AC 448 ms 30800 KiB
random_02.txt AC 428 ms 30676 KiB
random_03.txt AC 451 ms 30760 KiB
random_04.txt AC 424 ms 30724 KiB
random_05.txt AC 413 ms 30680 KiB
random_06.txt AC 420 ms 30496 KiB
random_07.txt AC 394 ms 30596 KiB
random_08.txt AC 413 ms 30692 KiB
random_09.txt AC 418 ms 30716 KiB
random_10.txt AC 412 ms 30856 KiB
sample_01.txt AC 406 ms 30636 KiB
sample_02.txt AC 403 ms 30636 KiB
sample_03.txt AC 450 ms 30604 KiB