結果

問題 No.816 Beautiful tuples
ユーザー gemmarogemmaro
提出日時 2020-07-04 15:41:22
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 265 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 11,916 KB
実行使用メモリ 23,052 KB
最終ジャッジ日時 2023-10-19 06:44:03
合計ジャッジ時間 3,547 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
23,052 KB
testcase_01 AC 87 ms
16,040 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 != A && _1 != B } || -1
end

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

puts solve
0