結果

問題 No.1168 Digit Sum Sequence
ユーザー fukafukatani
提出日時 2020-10-04 21:08:13
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 400 bytes
コンパイル時間 14,414 ms
コンパイル使用メモリ 377,424 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-19 18:17:41
合計ジャッジ時間 16,093 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let mut n = read::<i64>();
    for _ in 0..100 {
        let ns = format!("{}", n);
        n = ns
            .chars()
            .map(|x| x.to_digit(10).unwrap() as i64)
            .sum::<i64>();
    }
    println!("{}", n);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
0