結果
| 問題 | 
                            No.106 素数が嫌い!2
                             | 
                    
| コンテスト | |
| ユーザー | 
                             ry0u_yd
                         | 
                    
| 提出日時 | 2015-09-02 12:39:34 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 34 ms / 5,000 ms | 
| コード長 | 1,015 bytes | 
| コンパイル時間 | 536 ms | 
| コンパイル使用メモリ | 72,488 KB | 
| 実行使用メモリ | 13,184 KB | 
| 最終ジャッジ日時 | 2024-07-18 17:49:01 | 
| 合計ジャッジ時間 | 1,403 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 13 | 
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
bool prime[10000000];
void Eratosthenes(int n) {
    rep(i,n) prime[i] = true;
    prime[1] = false;
    REP(i,2,(int)sqrt(n)) {
        if(prime[i]) {
            for(int j=0;i*(j+2)<n;j++) {
                prime[i*(j+2)] = 0;
            }
        }
    }
}
int main() {
    int n,k;
    cin >> n >> k;
    Eratosthenes(n+5);
    int cnt[2000005];
    memset(cnt,0,sizeof(cnt));
    REP(i,2,n+1) {
        if(prime[i]) {
            for(int j=i; j <= n; j += i) {
                cnt[j]++;
            }
        }
    }
    int ans = 0;
    REP(i,2,n+1) {
        if(cnt[i] >= k) ans++;
    }
    cout << ans << endl;
    return 0;
}
            
            
            
        
            
ry0u_yd