結果

問題 No.1298 OR XOR
ユーザー simansiman
提出日時 2020-11-28 12:19:43
言語 Ruby
(3.3.0)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 243 bytes
コンパイル時間 71 ms
コンパイル使用メモリ 11,208 KB
実行使用メモリ 15,328 KB
最終ジャッジ日時 2023-10-09 23:51:06
合計ジャッジ時間 2,136 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
15,108 KB
testcase_01 AC 75 ms
15,064 KB
testcase_02 AC 74 ms
15,172 KB
testcase_03 AC 78 ms
15,292 KB
testcase_04 AC 79 ms
15,104 KB
testcase_05 AC 75 ms
15,204 KB
testcase_06 AC 76 ms
15,036 KB
testcase_07 AC 75 ms
15,300 KB
testcase_08 AC 74 ms
15,056 KB
testcase_09 AC 77 ms
15,292 KB
testcase_10 AC 79 ms
15,328 KB
testcase_11 AC 78 ms
15,032 KB
testcase_12 AC 76 ms
15,288 KB
testcase_13 AC 78 ms
15,264 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i

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

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

    b *= 2
  end

  ans << (ans[0] ^ ans[1])
  puts ans.sort.join(' ')
end
0