結果
問題 |
No.939 and or
|
ユーザー |
|
提出日時 | 2020-01-13 19:33:56 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 1,001 bytes |
コンパイル時間 | 11,239 ms |
コンパイル使用メモリ | 402,680 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-21 14:35:33 |
合計ジャッジ時間 | 12,367 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 30 |
ソースコード
use std::io::Read; fn solve(a: usize, b: usize) { let bit_size = format!("{:b}", std::cmp::max(a, b)).len(); let mut result: u128 = 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); if result == 1 { println!("{}", result); } else { 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]); }