結果
| 問題 | No.638 Sum of "not power of 2" | 
| コンテスト | |
| ユーザー |  siman | 
| 提出日時 | 2020-11-30 18:29:44 | 
| 言語 | Ruby (3.4.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 92 ms / 1,000 ms | 
| コード長 | 241 bytes | 
| コンパイル時間 | 44 ms | 
| コンパイル使用メモリ | 7,552 KB | 
| 実行使用メモリ | 12,416 KB | 
| 最終ジャッジ日時 | 2024-09-13 02:28:26 | 
| 合計ジャッジ時間 | 2,171 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 12 | 
コンパイルメッセージ
Main.rb:21: warning: ambiguous first argument; put parentheses or a space even after `-' operator Syntax OK
ソースコード
N = gets.to_i
def is_power_of_2(x)
  while x > 1
    return false if x % 2 == 1
    x /= 2
  end
  true
end
1.upto(200) do |a|
  next if is_power_of_2(a)
  b = N - a
  next if is_power_of_2(b)
  puts [a, b].join(' ')
  exit
end
puts -1
            
            
            
        