結果

問題 No.683 Two Operations No.3
ユーザー phspls
提出日時 2023-01-01 22:41:40
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 745 bytes
コンパイル時間 11,483 ms
コンパイル使用メモリ 379,004 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-27 00:23:48
合計ジャッジ時間 12,482 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

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];

    let mut deque = VecDeque::new();
    deque.push_back((a, b));
    while let Some((x, y)) = deque.pop_front() {
        if x == 0 || y == 0 {
            println!("Yes");
            return;
        }
        if x % 2 == 0 {
            let nx = x / 2;
            let ny = y - 1;
            deque.push_back((nx, ny));
        }
        if y % 2 == 0 {
            let nx = x - 1;
            let ny = y / 2;
            deque.push_back((nx, ny));
        }
    }
    println!("No");
}
0