basic-algo-lecture/workbook/0x12.md at master · encrypted-def/basic-algo-lecture
basic-algo-lecture/workbook/0x12.md at master · encrypted-def/basic-algo-lecture
바킹독의 실전 알고리즘 강의 자료. Contribute to encrypted-def/basic-algo-lecture development by creating an account on GitHub.
github.com
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
using namespace std;
int main(void) {
ios::sync_with_stdio(0);
cin.tie(0);
int n, k;
cin >> n >> k;
vector<bool> state(n + 1, true);
for (int i = 2; i <= n; i++) {
if (!state[i]) continue;
for (int j = i; j <= n; j += i) {
if (!state[j]) continue;
state[j] = false;
k--;
if (k == 0) {
cout << j;
return 0;
}
}
}
}