結果
| 問題 | No.683 Two Operations No.3 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-12-25 15:05:34 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 961 bytes |
| 記録 | |
| コンパイル時間 | 13,081 ms |
| コンパイル使用メモリ | 383,964 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-19 03:52:45 |
| 合計ジャッジ時間 | 13,152 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 |
ソースコード
use std::collections::VecDeque;
fn main() {
let mut ab = String::new();
std::io::stdin().read_line(&mut ab).ok();
let ab: Vec<usize> = ab.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
let a = ab[0];
let b = ab[1];
if a == 0 && b == 0 {
println!("Yes");
return;
}
let mut deque = VecDeque::new();
deque.push_back((a, b));
while let Some((x, y)) = deque.pop_front() {
if x % 2 == 0 && y > 0 {
let nx = x / 2;
let ny = y - 1;
if nx == 0 || ny == 0 {
println!("Yes");
return;
}
deque.push_back((nx, ny));
}
if x > 0 && y % 2 == 0 {
let nx = x - 1;
let ny = y / 2;
if nx == 0 || ny == 0 {
println!("Yes");
return;
}
deque.push_back((nx, ny));
}
}
println!("No");
}