結果

問題 No.1298 OR XOR
ユーザー 👑 horiesinitihoriesiniti
提出日時 2023-01-19 00:57:40
言語 Ruby
(3.3.0)
結果
AC  
実行時間 84 ms / 2,000 ms
コード長 291 bytes
コンパイル時間 49 ms
コンパイル使用メモリ 11,628 KB
実行使用メモリ 15,388 KB
最終ジャッジ日時 2023-09-02 18:00:45
合計ジャッジ時間 2,771 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
15,232 KB
testcase_01 AC 79 ms
15,056 KB
testcase_02 AC 80 ms
15,144 KB
testcase_03 AC 84 ms
15,060 KB
testcase_04 AC 79 ms
15,204 KB
testcase_05 AC 78 ms
15,088 KB
testcase_06 AC 79 ms
15,180 KB
testcase_07 AC 80 ms
15,064 KB
testcase_08 AC 79 ms
15,136 KB
testcase_09 AC 80 ms
15,388 KB
testcase_10 AC 78 ms
15,172 KB
testcase_11 AC 78 ms
15,216 KB
testcase_12 AC 79 ms
15,148 KB
testcase_13 AC 80 ms
15,172 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n=gets.to_i.digits(2).reverse
i=0
if n.count{|e| e==1}==1 then
	puts "-1 -1 -1"
else
	as=["","",""]
	i=0
	n.each{|e|
		s="000"
		if e==0 then
		elsif i%2==0 
			s="110"
			i+=1
		else
			s="101"
			i+=1
		end
		3.times{|i|
			as[i]+=s[i]
		}
	}
	puts as.map{|e| e.to_i(2)}.sort.join(" ")
end
0