結果

問題 No.106 素数が嫌い!2
ユーザー sggkshiosggkshio
提出日時 2017-06-19 01:01:57
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 276 ms / 5,000 ms
コード長 836 bytes
コンパイル時間 514 ms
コンパイル使用メモリ 82,384 KB
実行使用メモリ 13,292 KB
最終ジャッジ日時 2024-04-09 20:58:50
合計ジャッジ時間 5,631 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 267 ms
13,160 KB
testcase_01 AC 251 ms
13,168 KB
testcase_02 AC 253 ms
13,164 KB
testcase_03 AC 250 ms
13,164 KB
testcase_04 AC 263 ms
13,164 KB
testcase_05 AC 272 ms
13,164 KB
testcase_06 AC 275 ms
13,164 KB
testcase_07 AC 265 ms
13,160 KB
testcase_08 AC 271 ms
13,292 KB
testcase_09 AC 276 ms
13,036 KB
testcase_10 AC 274 ms
13,164 KB
testcase_11 AC 265 ms
13,292 KB
testcase_12 AC 269 ms
13,292 KB
testcase_13 AC 252 ms
13,292 KB
testcase_14 AC 249 ms
13,168 KB
testcase_15 AC 259 ms
13,292 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>

//#include<bits/stdc++.h>


using namespace std;

bool f[2000005];
int a[2000005];
int main() {

	for(int i=3;i<=2000000;i+=2)
		for (int j = 3; j*j <= i; j += 2) {
			if (i%j == 0) {
				f[i] = 1; break;
			}
		}
	//f[2] = 1;

	int n, m;
	cin >> n >> m;
	int s = 0;
	for (int i = 2; i <= n; i++) {
		if (i % 2 == 0 && i != 2)continue;
		if (!f[i]) {
			for (int j = i; j <= 2000000; j += i) {
				a[j]++;
			}
		}
	}
	for (int i = 2; i <= n; i++) {
		if (a[i] >= m) {
			s++; //cout << i << endl;
		}
	}
	cout << s << endl;
	return 0;
}
0