結果

問題 No.889 素数!
コンテスト
ユーザー akakimidori
提出日時 2019-09-20 21:40:56
言語 Rust
(1.97.1 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 0 ms / 2,000 ms
+ 817µs
コード長 916 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 454 ms
コンパイル使用メモリ 180,028 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-08-27 07:16:09
合計ジャッジ時間 3,271 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 61
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let n: u32 = s.trim().parse().unwrap();
    if n <= 1 {
        println!("{}", n);
        return;
    }
    let mut prime = true;
    let mut k = 2;
    while k * k <= n {
        if n % k == 0 {
            prime = false;
        }
        k += 1;
    }
    if prime {
        println!("Sosu!");
        return;
    }
    if (k - 1) * (k - 1) == n {
        println!("Heihosu!");
        return;
    }
    let mut k = 2;
    while k * k * k < n {
        k += 1;
    }
    if k * k * k == n {
        println!("Ripposu!");
        return;
    }
    let mut sum = 0;
    let mut k = 1;
    while k * k < n {
        if n % k == 0 {
            sum += k + n / k;
        }
        k += 1;
    }
    if sum == 2 * n {
        println!("Kanzensu!");
        return;
    }
    println!("{}", n);
}

fn main() {
    run();
}
0