SHARE
TWEET

Untitled

a guest Feb 21st, 2020 71 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.     if(k <= 1) return 0;
  8.     for(int i = 2; i * i <= k; i++)
  9.         if(k % i == 0)
  10.             return 0;
  11.     return 1;
  12. }
  13.  
  14. int main() {
  15.     freopen("coriandru.in", "r", stdin);
  16.     freopen("coriandru.out", "w", stdout);
  17.     cin >> n >> k;
  18.     for(int i = 1; i <= n; i++) cin >> a[i];
  19.     sort(a + 1, a + n + 1);
  20.    
  21.     for(nr = 1;k ; nr++)
  22.         k -= isPrime(nr);
  23.     nr--; nr %= n; nr = n + 1 - nr; a[0] = a[n];
  24.     a[n + 1] = a[1];
  25.    
  26.     cout << a[nr] << ' ' << a[nr - 1] << '\n';
  27.  
  28. }
  29.  
  30.  
  31. /*
  32.  
  33. 0 - 1
  34. 1 - 2
  35. 2 - 3
  36. ..
  37.  
  38.  
  39. n-1 - n
  40. */
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