結果

問題 No.1298 OR XOR
ユーザー tamura2004tamura2004
提出日時 2021-01-21 23:14:41
言語 Ruby
(3.3.0)
結果
AC  
実行時間 80 ms / 2,000 ms
コード長 209 bytes
コンパイル時間 535 ms
コンパイル使用メモリ 11,344 KB
実行使用メモリ 15,332 KB
最終ジャッジ日時 2023-08-26 14:46:58
合計ジャッジ時間 2,228 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,088 KB
testcase_01 AC 75 ms
15,160 KB
testcase_02 AC 75 ms
15,092 KB
testcase_03 AC 75 ms
15,032 KB
testcase_04 AC 80 ms
15,324 KB
testcase_05 AC 75 ms
15,168 KB
testcase_06 AC 75 ms
15,220 KB
testcase_07 AC 75 ms
15,168 KB
testcase_08 AC 75 ms
15,316 KB
testcase_09 AC 75 ms
15,308 KB
testcase_10 AC 76 ms
15,132 KB
testcase_11 AC 76 ms
15,148 KB
testcase_12 AC 75 ms
15,332 KB
testcase_13 AC 75 ms
15,220 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.to_s.to_i
if n.to_s(2).count("1") <= 1
  puts "-1 -1 -1"
  exit
end

a = n
b = n
c = 0

30.times do |i|
  if n[i] == 1
    c |= 1 << i
    a &= ~(1 << i)
    break
  end
end

puts [a, b, c].join(" ")
0