結果

問題 No.106 素数が嫌い!2
ユーザー tonyu0tonyu0
提出日時 2020-03-29 18:38:23
言語 Rust
(1.77.0)
結果
AC  
実行時間 54 ms / 5,000 ms
コード長 803 bytes
コンパイル時間 719 ms
コンパイル使用メモリ 144,860 KB
実行使用メモリ 20,644 KB
最終ジャッジ日時 2023-08-30 19:55:47
合計ジャッジ時間 1,846 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
11,296 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 24 ms
11,296 KB
testcase_05 AC 51 ms
20,548 KB
testcase_06 AC 50 ms
20,636 KB
testcase_07 AC 54 ms
20,620 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 51 ms
20,644 KB
testcase_11 AC 20 ms
10,308 KB
testcase_12 AC 49 ms
19,944 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::*;

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: usize = itr.next().unwrap().parse().unwrap();
    let k: usize = itr.next().unwrap().parse().unwrap();

    let mut table: Vec<usize> = vec![0; n + 1];
    let mut prime = Vec::new();
    let mut is_prime: Vec<bool> = vec![true; n + 1];
    for i in 2..n + 1 {
        if is_prime[i] {
            prime.push(i);
            let mut j = i;
            while j <= n {
                table[j] += 1;
                is_prime[j] = false;
                j += i;
            }
        }
    }

    let mut ans = 0;
    for i in 0..n + 1 {
        if table[i] >= k {
            ans += 1;
        }
    }
    println!("{}", ans);
}
0