結果

問題 No.106 素数が嫌い!2
ユーザー ku_material_roku_material_ro
提出日時 2016-09-28 11:00:50
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 29 ms / 5,000 ms
コード長 623 bytes
コンパイル時間 591 ms
コンパイル使用メモリ 59,436 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-05-01 06:10:01
合計ジャッジ時間 1,400 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
11,264 KB
testcase_01 AC 8 ms
11,264 KB
testcase_02 AC 8 ms
11,264 KB
testcase_03 AC 8 ms
11,136 KB
testcase_04 AC 15 ms
11,264 KB
testcase_05 AC 29 ms
11,136 KB
testcase_06 AC 29 ms
11,008 KB
testcase_07 AC 29 ms
11,136 KB
testcase_08 AC 9 ms
11,264 KB
testcase_09 AC 9 ms
11,264 KB
testcase_10 AC 29 ms
11,264 KB
testcase_11 AC 14 ms
11,264 KB
testcase_12 AC 28 ms
11,264 KB
testcase_13 AC 8 ms
11,264 KB
testcase_14 AC 8 ms
11,136 KB
testcase_15 AC 8 ms
11,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<math.h>
using namespace std;

/*int sosu(long long N){
	long long A;
	int J = 0;
	for (long long i1 = 2; i1 < N/2; i1++){
		A = (N / i1)*i1;
		if (A == N){
			J = 1;
			break;
		}
	}
	return J;

}*/

int main(){
	long long n;
	int k;
	int d[2000000] = {0};
	int cnt = 0;
	int cnt1 = 0;
	int ans = 0;
	cin >> n >> k;
	if (k > 1){
		for (long long i1 = 2; i1 < n + 1; i1++){
			if (d[i1] == 0){
				for (long long i = i1 * 2; i < n + 1; i += i1){
					d[i]++;
				}
			}

			
			if (d[i1] >= k) ans++;
			
		}
	}
	else{
		ans = n - 1;
	}

		cout << ans << endl;


	

	return 0;
}
0