結果

問題 No.36 素数が嫌い!
ユーザー tonyu0tonyu0
提出日時 2020-03-24 16:31:19
言語 Rust
(1.77.0)
結果
AC  
実行時間 96 ms / 5,000 ms
コード長 754 bytes
コンパイル時間 694 ms
コンパイル使用メモリ 147,396 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-30 05:35:01
合計ジャッジ時間 3,129 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
4,376 KB
testcase_01 AC 74 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 31 ms
4,376 KB
testcase_12 AC 93 ms
4,376 KB
testcase_13 AC 93 ms
4,380 KB
testcase_14 AC 58 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 36 ms
4,376 KB
testcase_20 AC 96 ms
4,376 KB
testcase_21 AC 71 ms
4,380 KB
testcase_22 AC 73 ms
4,376 KB
testcase_23 AC 44 ms
4,380 KB
testcase_24 AC 63 ms
4,380 KB
testcase_25 AC 49 ms
4,376 KB
testcase_26 AC 89 ms
4,380 KB
testcase_27 AC 81 ms
4,380 KB
testcase_28 AC 87 ms
4,380 KB
testcase_29 AC 90 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::Read;

fn is_prime(n: u64) -> bool {
    let mut m = 2;
    while m * m <= n {
        if n % m == 0 {
            return false;
        }
        m += 1;
    }
    true
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: u64 = itr.next().unwrap().parse().unwrap();

    let mut m = 2u64;
    let mut div = Vec::new();
    while m * m <= n {
        if n % m == 0 {
            div.push(m);
            if n / m != m {
                div.push(n / m);
            }
        }
        m += 1;
    }

    for a in div {
        if !is_prime(a) {
            println!("YES");
            return;
        }
    }
    println!("NO");
}
0