結果

問題 No.939 and or
ユーザー phsplsphspls
提出日時 2020-01-13 19:13:45
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,034 bytes
コンパイル時間 13,884 ms
コンパイル使用メモリ 386,400 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-01 08:58:47
合計ジャッジ時間 15,248 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
6,812 KB
testcase_02 WA -
testcase_03 AC 1 ms
6,940 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 1 ms
6,944 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 1 ms
6,940 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 1 ms
6,940 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 1 ms
6,940 KB
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::Read;

fn solve(a: usize, b: usize) {
    if b > a && format!("{:b}", a).len() < format!("{:b}", b).len() {
        println!("{}", 0);
        return;
    }
    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' {
                    0
                } else {
                    2
                }
            } else {
                if pair.1 == '0' {
                    0
                } else {
                    1
                }
            }
        })
        .for_each(|i| result *= i);
    println!("{}", result);
}

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