結果

問題 No.106 素数が嫌い!2
ユーザー bal4ubal4u
提出日時 2019-04-12 13:10:50
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 34 ms / 5,000 ms
コード長 761 bytes
コンパイル時間 1,365 ms
コンパイル使用メモリ 28,876 KB
実行使用メモリ 11,696 KB
最終ジャッジ日時 2023-10-12 00:29:59
合計ジャッジ時間 3,030 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
11,620 KB
testcase_01 AC 26 ms
11,484 KB
testcase_02 AC 27 ms
11,616 KB
testcase_03 AC 27 ms
11,592 KB
testcase_04 AC 29 ms
11,488 KB
testcase_05 AC 30 ms
11,688 KB
testcase_06 AC 28 ms
11,540 KB
testcase_07 AC 28 ms
11,648 KB
testcase_08 AC 27 ms
11,488 KB
testcase_09 AC 27 ms
11,492 KB
testcase_10 AC 28 ms
11,652 KB
testcase_11 AC 27 ms
11,552 KB
testcase_12 AC 34 ms
11,696 KB
testcase_13 AC 26 ms
11,488 KB
testcase_14 AC 26 ms
11,692 KB
testcase_15 AC 27 ms
11,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// yukicoder: No.106 素数が嫌い!2
// 2019.4.12 bal4u
// Catalan(カタラン数)の計算
// c_0 = 1, c_n = c_n-1*2*(2n-1)/(n+1)

#include <stdio.h>

#include <stdio.h>
#include <ctype.h>

#define MAX  2000000
#define SQRT 1414
char notPrime[MAX+5] = { 1,1,0,0,1 };			// zero: if prime
int factor[MAX+5];

void sieve()
{
	int i, j;
	for (i = 3; i <= SQRT; i += 2) if (!notPrime[i]) {
		for (j = i * i; j <= MAX; j += i) notPrime[j] = 1;
	}
	for (i = 2; i <= MAX; i += 2) factor[i] = 1;
	for (i = 3; i <= MAX; i += 2) if (!notPrime[i]) {
		for (j = i; j <= MAX; j += i) factor[j]++;
	}
}

int main()
{
	int i, N, K, ans;
	sieve();
	scanf("%d%d", &N, &K);
	ans = 0; for (i = 2; i <= N; i++) if (factor[i] >= K) ans++;
	printf("%d\n", ans);
	return 0;
}
0