그대로 구현하는 문제였다
처음에 착각하고 소수 제외했는데 그거 포함해서 지워지는 거였다
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <functional>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define xx first
#define yy second
#define all(x) (x).begin(), (x).end()
using namespace std;
using i64 = long long;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;
bool check[1005];
int main() {
int n, k;
scanf("%d %d", &n, &k);
int cnt = 0;
for (int i = 2; i <= n; i++)
{
if (check[i])
continue;
for (int j = i; j <= n ; j += i) {
if (check[j])
continue;
if (++cnt == k)
printf("%d\n", j);
check[j] = true;
}
}
return 0;
}
'백준' 카테고리의 다른 글
10158 개미 (0) | 2021.08.28 |
---|---|
3048 개미 (0) | 2021.08.16 |
1907 탄소 화합물 (0) | 2021.08.08 |
1783 병든 나이트 (0) | 2021.08.07 |
14881 물통 문제 (2) | 2021.08.07 |