結果

問題 No.106 素数が嫌い!2
ユーザー hanbei_dayohanbei_dayo
提出日時 2020-07-25 18:24:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 467 ms / 5,000 ms
コード長 1,050 bytes
コンパイル時間 773 ms
コンパイル使用メモリ 96,924 KB
実行使用メモリ 21,156 KB
最終ジャッジ日時 2023-09-09 19:14:26
合計ジャッジ時間 9,708 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 464 ms
20,976 KB
testcase_01 AC 462 ms
20,880 KB
testcase_02 AC 461 ms
20,884 KB
testcase_03 AC 464 ms
21,148 KB
testcase_04 AC 464 ms
20,996 KB
testcase_05 AC 467 ms
21,156 KB
testcase_06 AC 463 ms
20,960 KB
testcase_07 AC 464 ms
21,152 KB
testcase_08 AC 460 ms
20,984 KB
testcase_09 AC 461 ms
20,892 KB
testcase_10 AC 463 ms
20,900 KB
testcase_11 AC 459 ms
20,904 KB
testcase_12 AC 466 ms
20,976 KB
testcase_13 AC 459 ms
20,892 KB
testcase_14 AC 460 ms
20,964 KB
testcase_15 AC 459 ms
20,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include<random>
#include <bitset>
using namespace std;
#define N (1000000000+7)
//#define N 998244353
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> Q;

const int inf = (int)1e9; 

ll gcd(ll a, ll b) {
	if (b > a) {
		ll tmp = b;
		b = a;
		a = tmp;
	}
	if (a%b == 0)return b;
	else return gcd(b, a%b);
}

bool prime[2000010];
ll num[2000010];
void furui() {
	int i = 2;
	while (i <= 2000000) {
		int j = 2;
		while (j*j <= i && !prime[i]) {
			if (i%j == 0) {
				prime[i] = true;
				break;
			}
			else j++;
		}
		int z = 2;
		if(!prime[i])num[i]=1;
		while (!prime[i]) {
			if (i*z <= 2000000) {
				prime[i*z] = true;
				num[i*z]++;
				z++;
			}
			else break;
		}
		i++;
	}
}

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