結果

問題 No.106 素数が嫌い!2
ユーザー kenta255kenta255
提出日時 2020-03-08 15:32:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,782 bytes
コンパイル時間 1,182 ms
コンパイル使用メモリ 119,620 KB
実行使用メモリ 11,520 KB
最終ジャッジ日時 2024-04-24 21:35:18
合計ジャッジ時間 1,949 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 26 ms
11,264 KB
testcase_07 AC 26 ms
11,264 KB
testcase_08 WA -
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 25 ms
11,520 KB
testcase_11 AC 11 ms
6,912 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 2 ms
5,376 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(x+1,true);
	vector<int> cnt(x+1,0);
	int ans = 0;
	isp[0]=isp[1]=false;
	for(int i=2;i*i<=x;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