結果

問題 No.106 素数が嫌い!2
ユーザー hotpepsihotpepsi
提出日時 2014-12-20 00:13:28
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 32 ms / 5,000 ms
コード長 472 bytes
コンパイル時間 868 ms
コンパイル使用メモリ 63,976 KB
実行使用メモリ 11,152 KB
最終ジャッジ日時 2023-09-02 19:34:00
合計ジャッジ時間 1,982 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
7,204 KB
testcase_01 AC 1 ms
4,368 KB
testcase_02 AC 1 ms
4,372 KB
testcase_03 AC 1 ms
4,372 KB
testcase_04 AC 14 ms
7,224 KB
testcase_05 AC 32 ms
11,144 KB
testcase_06 AC 32 ms
11,152 KB
testcase_07 AC 32 ms
11,144 KB
testcase_08 AC 3 ms
4,368 KB
testcase_09 AC 3 ms
4,372 KB
testcase_10 AC 32 ms
11,108 KB
testcase_11 AC 13 ms
7,004 KB
testcase_12 AC 30 ms
10,780 KB
testcase_13 AC 2 ms
4,368 KB
testcase_14 AC 2 ms
4,372 KB
testcase_15 AC 2 ms
4,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <sstream>
#include <vector>

using namespace std;

int main(int argc, char *argv[])
{
	cout.precision(16);
	string s;
	getline(cin, s);
	stringstream ss(s);
	int N, K;
	ss >> N >> K;
	static int f[2000001];
	for (int i = 2; i <= N; ++i) {
		if (!f[i]) {
			for (int j = i; j <= N; j += i) {
				f[j] += 1;
			}
		}
	}
	int ans = 0;
	for (int i = 2; i <= N; ++i) {
		ans += f[i] >= K;
	}
	cout << ans << endl;
	return 0;
}
0