結果

問題 No.2766 Delicious Multiply Spice
コンテスト
ユーザー Sai Srinivas A
提出日時 2024-05-31 21:42:20
言語 Rust
(1.94.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 910 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 11,470 ms
コンパイル使用メモリ 203,020 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-27 18:20:29
合計ジャッジ時間 5,153 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 8
other AC * 31
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused import: `std::cmp::max`
 --> src/main.rs:1:5
  |
1 | use std::cmp::max;
  |     ^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` (part of `#[warn(unused)]`) on by default

warning: unused variable: `test_cases`
  --> src/main.rs:27:9
   |
27 |     let test_cases:u32;
   |         ^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_test_cases`
   |
   = note: `#[warn(unused_variables)]` (part of `#[warn(unused)]`) on by default

warning: variable `INPUT` should have a snake case name
  --> src/main.rs:29:13
   |
29 |     let mut INPUT = io::BufReader::new(stdin.lock()).lines().map(Result::unwrap);
   |             ^^^^^ help: convert the identifier to snake case: `input`
   |
   = note: `#[warn(non_snake_case)]` (part of `#[warn(nonstandard_style)]`) on by default

warning: variable `OUTPUT` should have a snake case name
  --> src/main.rs:30:13
   |
30 |     let mut OUTPUT = io::BufWriter::new(io::stdout().lock());
   |             ^^^^^^ help: convert the identifier to snake case: `output`

warning: unused `Result` that must be used
  --> src/main.rs:37:5
   |
37 |     writeln!(OUTPUT, "{}", solve(n).unwrap());
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: this `Result` may be an `Err` variant, which should be handled
   = note: `#[warn(unused_must_use)]` (part of `#[warn(unused)]`) on by default
help: use `let _ = ...` to ignore the resulting value
   |
37 |     let _ = writeln!(OUTPUT, "{}", solve(n).unwrap());
   |     +++++++

ソースコード

diff #
raw source code

use std::cmp::max;
use std::io;
use std::io::{Write, BufRead};

fn solve(n:u64) -> Option<String>{
    if n == 1{return Some(String::new());}

    let n = n-1;
    if n %2 ==0 {
        if let Some(mut s) = solve(n/2){
            s.push('A');
            return Some(s);
        }
    }

    if n %3 ==0 {
        if let Some(mut s) = solve(n/3){
            s.push('B');
            return Some(s);
        }
    }

    None
}

pub fn main(){
    let test_cases:u32;
    let stdin = io::stdin();
    let mut INPUT = io::BufReader::new(stdin.lock()).lines().map(Result::unwrap);
    let mut OUTPUT = io::BufWriter::new(io::stdout().lock());
    
    // test_cases = INPUT.next().unwrap().parse().unwrap();

    let n = INPUT.next().unwrap().parse::<u64>().unwrap();

    
    writeln!(OUTPUT, "{}", solve(n).unwrap());





//    for _ in 0..test_cases{

//    }
}
0