結果

問題 No.106 素数が嫌い!2
ユーザー mayoko_mayoko_
提出日時 2014-12-19 11:45:35
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 32 ms / 5,000 ms
コード長 764 bytes
コンパイル時間 671 ms
コンパイル使用メモリ 72,108 KB
実行使用メモリ 11,224 KB
最終ジャッジ日時 2023-09-02 19:17:27
合計ジャッジ時間 2,093 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
11,144 KB
testcase_01 AC 23 ms
11,088 KB
testcase_02 AC 23 ms
11,140 KB
testcase_03 AC 23 ms
11,156 KB
testcase_04 AC 25 ms
11,160 KB
testcase_05 AC 27 ms
11,084 KB
testcase_06 AC 25 ms
11,084 KB
testcase_07 AC 25 ms
11,224 KB
testcase_08 AC 23 ms
11,128 KB
testcase_09 AC 23 ms
11,132 KB
testcase_10 AC 25 ms
11,172 KB
testcase_11 AC 24 ms
11,092 KB
testcase_12 AC 32 ms
11,192 KB
testcase_13 AC 22 ms
11,144 KB
testcase_14 AC 22 ms
11,092 KB
testcase_15 AC 23 ms
11,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>

#define INF 1000000000

using namespace std;
typedef long long ll;

const int MAXN = 2001000;
int cnt[MAXN];

int n, k;

void init() {
    for (int i = 2; i < MAXN; i++) {
        if (cnt[i] == 0) {
            cnt[i] = 1;
            for (int j = 2; j * i < MAXN; j++) {
                cnt[i*j]++;
            }
        }
    }
}

int main(void) {
    init();
    cin >> n >> k;
    int ans = 0;
    for (int i = 2; i <= n; i++) {
        if (cnt[i] >= k) ans++;
    }
    cout << ans << endl;
    return 0;
}
0