結果

問題 No.2607 Add One Digit
ユーザー neko_the_shadow
提出日時 2024-01-26 09:52:20
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 562 bytes
コンパイル時間 12,828 ms
コンパイル使用メモリ 378,672 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-28 07:27:42
合計ジャッジ時間 13,781 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::{collections::HashSet, io};

fn main() {
    let n = read_line();
    let ret = run(n);
    println!("{}", ret);
}

fn run(mut n: String) -> usize {
    let mut set = HashSet::new();
    for i in 0..=n.len() {
        for x in '0'..='9' {
            n.insert(i, x);
            if !n.starts_with("0") {
                set.insert(n.clone());
            }
            n.remove(i);
        }
    }
    set.len()
}

fn read_line() -> String {
    let mut line = String::new();
    io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}
0