This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;typedef long double ld;typedef pair<int,int> pii;
#define F first
#define S second
#define PB push_back
#define MP make_pair
const ll mod = 1e9+7, N = 2e6+7, M = 2e6+7, INF = INT_MAX/10;
ll powe(ll x, ll y){ x = x%mod, y=y%(mod-1);ll ans = 1;while(y>0){if (y&1){ans = (1ll * x * ans)%mod;}y>>=1;x = (1ll * x * x)%mod;}return ans;}
void solve(){
ll n, k;
cin >> n >> k;
vector<ll> v = {1};
vector<ll> ans = {1};
ll x = pow(2, n-1);
while(x >= 1 || ans.size() < k)
{
for(size_t i=0; i<v.size(); i++)
ans.PB(v[i] + x);
x /= 2;
for(size_t i=v.size(); i<ans.size(); i++)
v.PB(ans[i]);
}
cout << ans[k-1] << '\n';
//for(size_t i=0; i<ans.size(); i++)
//cout << ans[i] << ' ';
}
signed main(){
fast;
int t = 1;
//cin >> t;
while(t--){
solve();
}
return 0;
}
Compilation message (stderr)
rack.cpp: In function 'void solve()':
rack.cpp:22:32: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
22 | while(x >= 1 || ans.size() < k)
| ~~~~~~~~~~~^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |