結果
| 問題 |
No.939 and or
|
| コンテスト | |
| ユーザー |
siman
|
| 提出日時 | 2020-08-29 05:23:06 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 95 ms / 2,000 ms |
| コード長 | 489 bytes |
| コンパイル時間 | 229 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 12,416 KB |
| 最終ジャッジ日時 | 2024-11-14 05:02:21 |
| 合計ジャッジ時間 | 4,852 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 30 |
コンパイルメッセージ
Syntax OK
ソースコード
A, B = gets.split.map(&:to_i) bits_a = [] bits_b = [] A.to_s(2).rjust(32, '0').reverse.each_char.with_index do |ch, idx| next if ch == '0' bits_a << idx end B.to_s(2).rjust(32, '0').reverse.each_char.with_index do |ch, idx| next if ch == '0' bits_b << idx end a = (bits_a & bits_b).size b = bits_b.size - a c = (bits_a - bits_b).size # p [:bits_a, bits_a] # p [:bits_b, bits_b] # p [:a, a, :b, b, :c, c] if c > 0 puts 0 elsif b == 0 puts 1 else puts (2 ** b) / 2 end
siman