結果

問題 No.106 素数が嫌い!2
ユーザー stone_725stone_725
提出日時 2018-07-05 10:53:35
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 845 bytes
コンパイル時間 1,918 ms
コンパイル使用メモリ 134,884 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-08-20 10:52:38
合計ジャッジ時間 2,783 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
4,376 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 11 ms
4,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 11 ms
4,384 KB
testcase_08 WA -
testcase_09 AC 11 ms
4,380 KB
testcase_10 AC 11 ms
4,380 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 11 ms
4,376 KB
testcase_14 AC 11 ms
4,376 KB
testcase_15 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:19:1: warning: non-void function does not return a value in all control paths [-Wreturn-type]
}
^
1 warning generated.

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

vector<int> primes(1, 2);
vector<bool> isPrime(static_cast<int>(2 * 1e6 + 1), true);

map<int, int> dp;

int cnt(int num) {
	if (num == 1) return 0;
	if (isPrime[num]) return 1;
	int res = 0;
	for (long long i = 0; primes[i] * primes[i] <= num; i++) {
		if (num % primes[i]) continue;
		res++;
		while (num % primes[i] == 0) num /= primes[i];
	}
}


void hawawa()
{
	int n, k;
	cin >> n >> k;
	isPrime[0] = isPrime[1] = false;
	for (long long i = 3; i <= 2 * 1e6; i += 2) {
		if (!isPrime[i]) continue;
		for (long long j = i * i; j <= 2 * 1e6; j += i) {
			isPrime[j] = false;
		}
		primes.push_back(i);
	}
	int ans = 0;
	for (int i = n; i >= 2; i--) {
		if (k <= cnt(i) ){
			ans++;
		}
	}
	cout << ans << "\n";
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	hawawa();
	return 0;
}
0