結果

問題 No.106 素数が嫌い!2
ユーザー sggkshiosggkshio
提出日時 2017-06-19 01:01:57
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 346 ms / 5,000 ms
コード長 836 bytes
コンパイル時間 1,841 ms
コンパイル使用メモリ 82,728 KB
実行使用メモリ 13,420 KB
最終ジャッジ日時 2023-07-25 02:31:29
合計ジャッジ時間 8,324 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 335 ms
13,420 KB
testcase_01 AC 323 ms
13,088 KB
testcase_02 AC 324 ms
13,152 KB
testcase_03 AC 325 ms
13,180 KB
testcase_04 AC 337 ms
13,164 KB
testcase_05 AC 341 ms
13,116 KB
testcase_06 AC 340 ms
13,164 KB
testcase_07 AC 341 ms
13,152 KB
testcase_08 AC 332 ms
13,084 KB
testcase_09 AC 334 ms
13,156 KB
testcase_10 AC 341 ms
13,104 KB
testcase_11 AC 335 ms
13,148 KB
testcase_12 AC 346 ms
13,104 KB
testcase_13 AC 321 ms
13,152 KB
testcase_14 AC 323 ms
13,108 KB
testcase_15 AC 327 ms
13,144 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