結果

問題 No.106 素数が嫌い!2
ユーザー かにかに
提出日時 2015-11-16 00:17:00
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 37 ms / 5,000 ms
コード長 1,806 bytes
コンパイル時間 855 ms
コンパイル使用メモリ 90,184 KB
実行使用メモリ 13,380 KB
最終ジャッジ日時 2023-10-11 16:38:31
合計ジャッジ時間 2,122 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
13,252 KB
testcase_01 AC 8 ms
13,124 KB
testcase_02 AC 8 ms
13,280 KB
testcase_03 AC 8 ms
13,128 KB
testcase_04 AC 18 ms
13,380 KB
testcase_05 AC 35 ms
13,128 KB
testcase_06 AC 34 ms
13,316 KB
testcase_07 AC 33 ms
13,124 KB
testcase_08 AC 9 ms
13,316 KB
testcase_09 AC 9 ms
13,124 KB
testcase_10 AC 34 ms
13,112 KB
testcase_11 AC 16 ms
13,116 KB
testcase_12 AC 37 ms
13,120 KB
testcase_13 AC 8 ms
13,124 KB
testcase_14 AC 8 ms
13,168 KB
testcase_15 AC 7 ms
13,124 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#define aLL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXISt(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define MAX 100000000
#define pb push_back
#define mp make_pair
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef pair<pair<int, int>, int> pp;
typedef long long ll;
int dx[] = { 0, 1, 0, -1 };
int dy[] = { -1, 0, 1, 0 };

int sttoi(std::string str) {
	int ret;
	std::stringstream ss; ss << str;
	ss >> ret;
	return ret;
}

bool sort_greater(const pair<string, int> &a, const pair<string, int> &b) {
	return a.second > b.second;
}
bool prime[2000001];

void Eratosthenes(int N){
	rep(i, 2000001)prime[i] = true;
	prime[1] = false;
	REP(i, 2, sqrt(N)){
		if (prime[i]){
			for (int j = 2; i*j < N; j++){
				prime[i*j] = false;
			}
		}
	}
}
int cnt[2000001];
void solve() {
	int n, m;
	cin >> n >> m;
	Eratosthenes(n+1);
	fill(cnt, cnt + 2000001, 0);
	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] >= m)ans++;
	}
	P(ans);
}

int main() {
	solve();
	return 0;
}
0