結果
問題 | No.816 Beautiful tuples |
ユーザー |
![]() |
提出日時 | 2020-11-09 17:12:10 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 87 ms / 1,500 ms |
コード長 | 536 bytes |
コンパイル時間 | 158 ms |
コンパイル使用メモリ | 7,424 KB |
実行使用メモリ | 12,544 KB |
最終ジャッジ日時 | 2024-07-22 16:15:17 |
合計ジャッジ時間 | 2,017 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 |
コンパイルメッセージ
Main.rb:29: warning: ambiguous first argument; put parentheses or a space even after `-' operator Syntax OK
ソースコード
class Integer def divisor_list require 'prime' return [] if self <= 0 return [1] if self == 1 prime_division.map.with_index { |(base, k), i| s = i.zero? ? 0 : 1 (s..k).map { |n| base ** n } }.inject { |res, e| res + res.flat_map { |t| e.map { |v| t * v } } }.sort end end A, B = gets.split.map(&:to_i).sort (A + B).divisor_list.each do |x| next if x > A + B next if x < B - A next if x == A next if x == B if (A + x) % B == 0 && (B + x) % A == 0 puts x exit end end puts -1