結果
問題 | No.2766 Delicious Multiply Spice |
ユーザー |
|
提出日時 | 2024-05-31 21:42:20 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 910 bytes |
コンパイル時間 | 13,928 ms |
コンパイル使用メモリ | 385,420 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-20 22:57:21 |
合計ジャッジ時間 | 15,406 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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)]` 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)]` 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)]` 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)]` on by default = note: this warning originates in the macro `writeln` (in Nightly builds, run with -Z macro-backtrace for more info)
ソースコード
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{ // } }