結果

問題 No.106 素数が嫌い!2
ユーザー goodbatongoodbaton
提出日時 2015-08-04 23:23:41
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 37 ms / 5,000 ms
コード長 997 bytes
コンパイル時間 525 ms
コンパイル使用メモリ 71,432 KB
実行使用メモリ 13,488 KB
最終ジャッジ日時 2023-09-25 01:10:58
合計ジャッジ時間 1,714 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
11,184 KB
testcase_01 AC 10 ms
7,056 KB
testcase_02 AC 10 ms
7,164 KB
testcase_03 AC 10 ms
7,176 KB
testcase_04 AC 20 ms
11,264 KB
testcase_05 AC 32 ms
13,376 KB
testcase_06 AC 31 ms
13,356 KB
testcase_07 AC 32 ms
13,308 KB
testcase_08 AC 12 ms
7,632 KB
testcase_09 AC 11 ms
7,700 KB
testcase_10 AC 32 ms
13,488 KB
testcase_11 AC 19 ms
11,264 KB
testcase_12 AC 37 ms
13,192 KB
testcase_13 AC 10 ms
7,188 KB
testcase_14 AC 10 ms
7,140 KB
testcase_15 AC 10 ms
7,228 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstring>

typedef long long ll;
using namespace std;

#define mod 1000000009
#define INF 10000000
#define LLINF 2000000000000000000LL

#define SIZE 101

const int MAX_P = 2000000;
bool prime[MAX_P+1];
void primen(void){
    for(int i=2;i<=MAX_P;i++)
        prime[i]=true;
    
    for(int i=2;i*i<=MAX_P;i++)
        if(prime[i])
            for(int j=i;i*j<=MAX_P;j++)
                prime[i*j]=false;
    
}

int n,k,num[2000001]={0},ans=0;

int main(){
    
    scanf("%d%d",&n,&k);
    
    primen();
    
    for(int i=2;i<=n;i++){
        if(prime[i]){
            for(int j=i;j<=n;j+=i){
                num[j]++;
            }
        }
    }
    
    for(int i=2;i<=n;i++){
        if(num[i]>=k){
            ans++;
        }
    }
    
    printf("%d\n",ans);
    
    return 0;
}
0