結果

問題 No.1298 OR XOR
ユーザー universatouniversato
提出日時 2020-11-27 22:21:18
言語 Ruby
(3.3.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 735 bytes
コンパイル時間 436 ms
コンパイル使用メモリ 11,336 KB
実行使用メモリ 15,248 KB
最終ジャッジ日時 2023-10-01 06:33:58
合計ジャッジ時間 3,322 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
14,952 KB
testcase_01 AC 87 ms
15,248 KB
testcase_02 AC 83 ms
15,240 KB
testcase_03 AC 85 ms
15,068 KB
testcase_04 AC 86 ms
15,084 KB
testcase_05 AC 85 ms
15,240 KB
testcase_06 AC 83 ms
15,040 KB
testcase_07 AC 85 ms
15,044 KB
testcase_08 AC 83 ms
15,044 KB
testcase_09 AC 84 ms
15,236 KB
testcase_10 AC 84 ms
15,080 KB
testcase_11 AC 85 ms
15,240 KB
testcase_12 AC 85 ms
15,028 KB
testcase_13 AC 84 ms
15,076 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.to_s.to_i

t = n
t /= 2 while t.even?
if t == 1
  puts "-1 -1 -1"
  exit
end

c = n
a = n.to_s(2)[1..-1].to_i(2)
b = a ^ c

puts "#{a} #{b} #{c}"



# C == N
# A or B == N
# A xor B xor C == N -> A xor B == N

# p 2**30
# kanou = []
# (1..33).each do |i|
#   (i..33).each do |j|
#     next if i == j
#     k = i^j
#     n = (i | j)
#     kanou << [i, j, k, i.to_s(2), j.to_s(2), k.to_s(2), n.to_s(2), (i | k).to_s(2), (k | j).to_s(2), (k | j)] if n == (i | k) && n == (j | k) #&& n == 6
#   end
# end

# pp kanou.sort_by(&:last)

# 0b11
# 0b01
# 0b10
# 0b11





# ans = prob.numerator * prob.denominator.pow(mod - 2, mod) % mod

# puts ans 

# [1, 2, 3]
# 1 [(1+1), (2+1), (3+1)] -> []
# 2 [(1+2), (2+2), (3+2)]
# 3 [4, 5, 6]
0