Guest User

Untitled

a guest
May 24th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int main() {
  6. int n, k, i,j;
  7. int arr[1001] = { 0 };
  8. vector<int> p;
  9. cin >> n >> k;
  10. for (i = 2; i <= n; i++) {
  11. arr[i] = i;
  12. }
  13. for (i = 2; i <= n; i++) {
  14. if (arr[i] != 0) {
  15. p.push_back(i);
  16. for (j = i * 2; j <= n; j += i) {
  17. if (arr[j] != 0) {
  18. p.push_back(j);
  19. arr[j] = 0;
  20. }
  21. }
  22. }
  23. }
  24. cout << p[k - 1] << '\n';
  25. return 0;
  26. }
Add Comment
Please, Sign In to add comment