結果

問題 No.2766 Delicious Multiply Spice
コンテスト
ユーザー あさくち
提出日時 2024-05-31 21:33:16
言語 Rust
(1.94.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
TLE  
実行時間 -
コード長 615 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,003 ms
コンパイル使用メモリ 188,928 KB
実行使用メモリ 8,448 KB
最終ジャッジ日時 2026-05-27 18:06:44
合計ジャッジ時間 6,929 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 8
other AC * 24 TLE * 1 -- * 6
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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