結果
| 問題 | No.816 Beautiful tuples | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2019-04-19 21:27:49 | 
| 言語 | Ruby (3.4.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 92 ms / 1,500 ms | 
| コード長 | 300 bytes | 
| コンパイル時間 | 240 ms | 
| コンパイル使用メモリ | 7,552 KB | 
| 実行使用メモリ | 12,288 KB | 
| 最終ジャッジ日時 | 2024-09-22 16:29:58 | 
| 合計ジャッジ時間 | 2,166 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 15 | 
コンパイルメッセージ
Main.rb:17: warning: ambiguous first argument; put parentheses or a space even after `-' operator Syntax OK
ソースコード
a, b = gets.split.map(&:to_i)
s = a+b
ans = []
(1..s).each do |i|
    break if i*i > s
    next if s % i > 0
    [i, s/i].each do |c|
        if c != a && c != b && (b+c) % a == 0 && (c+a) % b == 0
            ans.push(c)
        end
    end
end
if ans.size > 0
    puts ans.min
else
    puts -1
end
            
            
            
        