結果

問題 No.889 素数!
ユーザー phspls
提出日時 2020-01-11 15:18:21
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 859 bytes
コンパイル時間 11,292 ms
コンパイル使用メモリ 385,224 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-24 23:49:06
合計ジャッジ時間 13,329 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 61
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::Read;

fn solve(n: usize) {
    if n < 2 {
        println!("{}", n);
    } else if vec![8, 27].contains(&n) {
        println!("{}", "Ripposu!");
    } else if (2..8).map(|i| i*i).collect::<Vec<usize>>().contains(&n) {
        println!("{}", "Heihosu!");
    } else {
        let mut yakusuu = vec![];
        for i in 2..n {
            if n % i == 0 {
                yakusuu.push(i);
            }
        }
        if yakusuu.len() == 0 {
            println!("{}", "Sosu!");
        } else if yakusuu.iter().sum::<usize>() == n - 1 {
            println!("{}", "Kanzensu!");
        } else {
            println!("{}", n);
        }
    }
}

fn main() {
    let mut n = String::new();
    std::io::stdin().read_to_string(&mut n).ok();
    let n: usize = n.trim().split('\n').next().unwrap().trim().parse::<usize>().unwrap();
    solve(n);
}
0