結果

問題 No.36 素数が嫌い!
ユーザー Maricom_tkg
提出日時 2018-11-16 21:26:39
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 20 ms / 5,000 ms
コード長 646 bytes
コンパイル時間 15,001 ms
コンパイル使用メモリ 378,232 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-24 14:16:09
合計ジャッジ時間 15,444 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    
    let mut n: u64 = buf.trim().parse().unwrap();
    
    let mut limit: u64 = (n as f64).powf(1./3.) as u64 + 1;
    let mut num: u64 = 2;
    let mut prime_count: usize = 0;
    while num <= limit && prime_count != 2 {
        if n % num == 0 {
            n /= num;
            limit = (n as f64).sqrt() as u64 + 1;
            prime_count += 1;
        } else {
            num += num%2 + 1;
        }
    }
    
    if prime_count == 2 && n > 1{
        println!("YES");
    } else {
        println!("NO")
    }
}
0