結果

問題 No.683 Two Operations No.3
ユーザー phsplsphspls
提出日時 2022-12-25 15:03:19
言語 Rust
(1.77.0)
結果
TLE  
実行時間 -
コード長 961 bytes
コンパイル時間 13,055 ms
コンパイル使用メモリ 379,664 KB
実行使用メモリ 8,736 KB
最終ジャッジ日時 2024-04-29 20:38:45
合計ジャッジ時間 14,663 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
8,736 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
権限があれば一括ダウンロードができます

ソースコード

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

    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");
}
0