結果
| 問題 |
No.939 and or
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-01-13 19:13:45 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,034 bytes |
| コンパイル時間 | 12,637 ms |
| コンパイル使用メモリ | 402,736 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-21 13:52:27 |
| 合計ジャッジ時間 | 13,972 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 1 |
| other | AC * 5 WA * 25 |
ソースコード
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]);
}