VioletaBabel
2960번: 에라토스테네스의 체 본문
#include <cstdio>
using namespace std;
int main()
{
int n, k, count = 0;
scanf("%d %d", &n, &k);
bool num[1001];
for (int i = 0; i <= n; ++i)
num[i] = 1;
for(int i = 2; i <= n; ++i)
for (int j = i; j <= n; j += i)
if (num[j] == 1)
{
num[j] = 0;
if (++count == k)
{
printf("%d", j);
return 1;
}
}
}
'백준 > 백준-C++' 카테고리의 다른 글
| 2581번: 소수 (0) | 2017.05.27 |
|---|---|
| 4948번: 베르트랑 공준 (0) | 2017.05.27 |
| 5054번: 주차의 신 (0) | 2017.05.26 |
| 1929번: 소수 구하기 (0) | 2017.05.26 |
| 1978번: 소수 찾기 (0) | 2017.05.26 |
Comments