結果

問題 No.36 素数が嫌い!
ユーザー Maricom_tkgMaricom_tkg
提出日時 2018-11-16 19:00:08
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 77 ms / 5,000 ms
コード長 579 bytes
コンパイル時間 15,114 ms
コンパイル使用メモリ 378,880 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-24 14:13:24
合計ジャッジ時間 15,884 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 limit: u64 = (n as f64).sqrt() as u64;
    let mut prime_count: usize = 0;
    let mut num: u64 = 2;
    while num <= limit && n > 1 {
        if prime_count >= 2 {
            println!("YES");
            return;
        }
        if n % num == 0 {
            n /= num;
            prime_count += 1;
        } else {
            num += num%2 + 1;
        }
    }
    
    println!("NO")
}
0