Ledger Nano X - The secure hardware wallet
SHARE
TWEET

743B.cpp

RWRI Mar 31st, 2020 82 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.  
  5. void fun(vector <int> &R,int k){
  6.     long long int a = R.size(), b = *max_element(R.begin(),R.end());
  7.  
  8.     if(a < k){
  9.         R.push_back(b+1);
  10.  
  11.         for(long long int i = 0;i < a;i++){
  12.             R.push_back(R[i]);
  13.         }
  14.     }
  15. }
  16.  
  17. int main(){
  18.     long long int n, k;
  19.  
  20.     cin >> n >> k;
  21.  
  22.     vector<int> R;
  23.     R.push_back(1);
  24.  
  25.     n--;
  26.     while(n--){
  27.         fun(R,k);
  28.     }
  29.  
  30.  
  31.     cout << R[k-1] << endl;
  32.  
  33. return 0;
  34.  
  35. }
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