結果

問題 No.939 and or
ユーザー magurofly
提出日時 2021-03-23 15:13:22
言語 Ruby
(3.4.1)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 240 bytes
コンパイル時間 44 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-11-25 07:04:46
合計ジャッジ時間 3,916 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 30
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

A, B = gets.split.map(&:to_i)

bits = 0
31.times do |i|
    if A[i] == 1 and B[i] == 0
        puts 0
        exit
    end
    if A[i] == 0 and B[i] == 1
        bits += 1
    end
end

if bits == 0
    puts 1
else
    puts 2**(bits - 1)
end
0