結果

問題 No.106 素数が嫌い!2
ユーザー elphe
提出日時 2024-07-10 18:10:46
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 61 ms / 5,000 ms
コード長 486 bytes
コンパイル時間 679 ms
コンパイル使用メモリ 70,752 KB
最終ジャッジ日時 2025-02-22 02:53:04
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

using namespace std;

int main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N, K, i, j, ans = 0;
    cin >> N >> K;
    vector<int> count(N + 1, 0);

    for (i = 2; i <= N; ++i)
    {
        if (count[i] == 0)
        {
            count[i] = 1;
            for (j = i * 2; j <= N; j += i)
                ++count[j];
        }

        if (count[i] >= K)
            ++ans;
    }

    cout << ans << '\n';
    return 0;
}
0