結果

問題 No.939 and or
ユーザー tonyu0
提出日時 2019-12-26 08:20:41
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 724 bytes
コンパイル時間 11,694 ms
コンパイル使用メモリ 379,820 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-10-02 12:31:13
合計ジャッジ時間 12,927 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::Read;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let a: usize = itr.next().unwrap().parse().unwrap();
    let mut b: usize = itr.next().unwrap().parse().unwrap();

    // まずaのビットがbで全部立ってるか確認
    let mut i: usize = 0;
    while a >> i > 0 || b >> i > 0 {
        if a >> i & 1 == 1 && b >> i & 1 == 0 {
            println!("0");
            return;
        }
        i += 1;
    }
    b ^= a;
    i = 0;
    let mut ans: u64 = 1;
    while b >> i > 0 {
        if b >> i & 1 == 1 {
            ans *= 2;
        }
        i += 1;
    }
    println!("{}", ans / 2);
}
0