結果

問題 No.106 素数が嫌い!2
ユーザー kenta255kenta255
提出日時 2020-03-08 16:03:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,800 bytes
コンパイル時間 1,172 ms
コンパイル使用メモリ 120,008 KB
実行使用メモリ 15,616 KB
最終ジャッジ日時 2024-04-24 22:35:06
合計ジャッジ時間 2,149 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 11 ms
15,360 KB
testcase_02 AC 11 ms
15,360 KB
testcase_03 AC 10 ms
15,616 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 34 ms
15,232 KB
testcase_07 AC 34 ms
15,488 KB
testcase_08 WA -
testcase_09 AC 12 ms
15,360 KB
testcase_10 AC 34 ms
15,360 KB
testcase_11 AC 19 ms
15,360 KB
testcase_12 WA -
testcase_13 AC 10 ms
15,488 KB
testcase_14 AC 11 ms
15,360 KB
testcase_15 AC 11 ms
15,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
#include <random>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(int I = int((B)-1); I >= int(A); --I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
const ll INF=1e18+7;
const ll MOD=1e9+7;


int make_p(int x,int k){
	vector<bool> isp(3000000+1,true);
	vector<int> cnt(3000000+1,0);
	int ans = 0;
	isp[0]=isp[1]=false;
	for(int i=2;i*i<=3000000;i++){
		if(isp[i]){
			cnt[i]++;
			for(int j=2*i;j<=x;j+=i){
				isp[j] = false;
				cnt[j]++;
			}
		}
	}
	for(int i=2;i<x+1;i++){
		ans += cnt[i] >= k;
	}
	return ans;
}

int main(){
	int N,K;
	cin >> N >> K;
	cout << make_p(N,K) << endl;
}
0