結果

問題 No.106 素数が嫌い!2
ユーザー yuppe19 😺yuppe19 😺
提出日時 2015-04-25 23:37:08
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 26 ms / 5,000 ms
コード長 537 bytes
コンパイル時間 1,322 ms
コンパイル使用メモリ 144,876 KB
実行使用メモリ 10,820 KB
最終ジャッジ日時 2023-09-18 11:34:01
合計ジャッジ時間 2,376 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
6,956 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 12 ms
6,956 KB
testcase_05 AC 26 ms
10,724 KB
testcase_06 AC 25 ms
10,712 KB
testcase_07 AC 25 ms
10,728 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 25 ms
10,820 KB
testcase_11 AC 10 ms
6,420 KB
testcase_12 AC 26 ms
10,624 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

vector<int> count(int n) {
    vector<int> res(n+1);
    fill(res.begin(), res.end(), 0);
    for(int i=2; i<=n; i++) {
        if(!res[i]) {
            for(int j=i; j<=n; j+=i) {
                res[j]++;
            }
        }
    }
    return res;
}

int main(void) {
    int n, k; scanf("%d%d", &n, &k);
    vector<int> counter = count(n);
    int res = 0;
    for(int i=0; i<counter.size(); i++) {
        if(counter[i] >= k) { res++; }
    }
    printf("%d\n", res);
    return 0;
}
0