SHARE
TWEET

Untitled

a guest Feb 21st, 2020 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. int n, k, a[1002001], nr;
  5.  
  6. bool isPrime(int k) {
  7.     for(int i = 2; i * i <= k; i++)
  8.         if(k % i == 0)
  9.             return 0;
  10.     return 1;
  11. }
  12.  
  13. int main() {
  14.     freopen("coriandru.in", "r", stdin);
  15.     freopen("coriandru.out", "w", stdout);
  16.     cin >> n >> k;
  17.     for(int i = 1; i <= n; i++) cin >> a[i];
  18.     sort(a + 1, a + n + 1);
  19.    
  20.     for(nr = 2;k ; nr++)
  21.         k -= isPrime(nr);
  22.     nr--; nr %= n; nr++; a[0] = a[n];
  23.    
  24.     cout << a[nr] << ' ' << a[nr - 1] << '\n';
  25.  
  26. }
  27.  
  28.  
  29. /*
  30.  
  31. 0 - 1
  32. 1 - 2
  33. 2 - 3
  34. ..
  35.  
  36.  
  37. n-1 - n
  38. */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top