結果

問題 No.2194 兄弟の掛け引き
ユーザー iwotiwot
提出日時 2023-02-17 16:52:10
言語 OCaml
(5.1.0)
結果
AC  
実行時間 3 ms / 1,000 ms
コード長 504 bytes
コンパイル時間 1,253 ms
コンパイル使用メモリ 19,668 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-26 15:23:32
合計ジャッジ時間 1,842 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

let solve a b c =
  let max_n = (c + b) / a in
  let rec solve_core n =
    if n > max_n then []
    else if n * a - b = c || n * a - b <= 0 && n * a = c then n :: solve_core (n+1)
    else solve_core (n+1)
  in solve_core 1

let rec print_list = function
  [] -> ()
  | a :: rest -> print_endline (string_of_int a); print_list rest

let _ =
  let a, b, c = Scanf.scanf "%d %d %d" (fun a b c -> a, b, c) in
  let ans = solve a b c in
  if List.length ans > 0 then print_list ans
  else print_endline "-1"
0