結果

問題 No.939 and or
ユーザー phspls
提出日時 2020-01-13 19:27:08
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 919 bytes
コンパイル時間 11,256 ms
コンパイル使用メモリ 401,680 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-21 14:20:13
合計ジャッジ時間 12,566 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 24 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::Read;

fn solve(a: usize, b: usize) {
    let bit_size = format!("{:b}", std::cmp::max(a, b)).len();
    let mut result = 1;
    format!("{:0>1$b}", a, bit_size).chars().zip(format!("{:0>1$b}", b, bit_size).chars())
        .map(|pair| {
            if pair.0 == '0' {
                if pair.1 == '0' {
                    1
                } else {
                    2
                }
            } else {
                if pair.1 == '0' {
                    0
                } else {
                    1
                }
            }
        })
        .for_each(|i| result *= i);
    println!("{}", result / 2);
}

fn main() {
    let mut ab = String::new();
    std::io::stdin().read_to_string(&mut ab).ok();
    let ab: Vec<usize> = ab.trim().split('\n').next().unwrap().trim().split_whitespace()
        .map(|i| i.parse::<usize>().unwrap())
        .collect();
    solve(ab[0], ab[1]);
}
0