結果

問題 No.1298 OR XOR
ユーザー simansiman
提出日時 2020-11-28 12:16:37
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 217 bytes
コンパイル時間 241 ms
コンパイル使用メモリ 11,556 KB
実行使用メモリ 15,348 KB
最終ジャッジ日時 2023-10-09 23:50:55
合計ジャッジ時間 3,351 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

N = gets.to_i

if N.to_s(2).count('1') <= 1
  puts [-1, -1, -1].join(' ')
else
  ans = [N]
  b = 1

  while ans.size <= 2
    if N & b > 0
      ans << (N ^ b)
    end

    b *= 2
  end

  puts ans.sort.join(' ')
end
0