結果

問題 No.816 Beautiful tuples
ユーザー gemmarogemmaro
提出日時 2020-07-04 15:37:19
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 243 bytes
コンパイル時間 459 ms
コンパイル使用メモリ 11,812 KB
実行使用メモリ 20,380 KB
最終ジャッジ日時 2023-10-19 06:39:39
合計ジャッジ時間 4,755 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 86 ms
16,032 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

# frozen_string_literal: true

def solve
  (1..(A + B))
    .select { ((A + B) % _1).zero? }
    .reverse
    .map { (A + B) / _1 }
    .find { ((B + _1) % A).zero? && ((_1 + A) % B).zero? } || -1
end

A, B = gets.split.map(&:to_i)

puts solve
0