結果

問題 No.2194 兄弟の掛け引き
ユーザー iwot
提出日時 2023-02-17 16:52:10
言語 OCaml
(5.2.1)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 504 bytes
コンパイル時間 1,682 ms
コンパイル使用メモリ 21,704 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-19 09:30:38
合計ジャッジ時間 1,542 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

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