結果
| 問題 | No.683 Two Operations No.3 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-01-08 23:42:35 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 921 bytes |
| 記録 | |
| コンパイル時間 | 13,572 ms |
| コンパイル使用メモリ | 378,792 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-16 03:43:39 |
| 合計ジャッジ時間 | 14,773 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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 {
let nx = x / 2;
let ny = y - 1;
if ny == 0 {
println!("Yes");
return;
}
deque.push_back((nx, ny));
}
if y % 2 == 0 {
let nx = x - 1;
let ny = y / 2;
if nx == 0 {
println!("Yes");
return;
}
deque.push_back((nx, ny));
}
}
println!("No");
}