結果

問題 No.2766 Delicious Multiply Spice
ユーザー あさくち
提出日時 2024-05-31 21:33:16
言語 Rust
(1.83.0 + proconio)
結果
TLE  
実行時間 -
コード長 615 bytes
コンパイル時間 28,841 ms
コンパイル使用メモリ 400,540 KB
実行使用メモリ 13,640 KB
最終ジャッジ日時 2024-12-20 22:36:26
合計ジャッジ時間 34,959 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 8
other AC * 26 TLE * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

use proconio::input;

// #[proconio::fastout]
fn main() {
    input! {
        n: usize,
    }

    let mut result = Vec::new();

    rec(n, 1, &mut result);

    let text: String = result.into_iter().rev().collect();
    println!("{}", text);
}

fn rec(n: usize, x: usize, result: &mut Vec<char>) -> bool {
    // println!("x {}", x);

    if x > n {
        return false;
    }

    if n == x {
        return true;
    }

    if rec(n, x * 2 + 1, result) {
        result.push('A');
        return true;
    }

    if rec(n, x * 3 + 1, result) {
        result.push('B');
        return true;
    }

    false
}
0