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 speed ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define nl '\n'
#define int long long
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
const int N = 1e6 + 5;
const int M = 1e3 + 5;
const int inf = 1e9 + 123;
const ll infl = 1e15 + 10;
const int mod = 1e9 + 7;
const int P = 31;
ll n, k;
vector <pair <string, int> > ans;
void go(int v, int tl, int tr, string s){
if(tl == tr){
reverse(all(s));
ans.pb(mp(s, tl));
return;
}
int tm = (tl + tr) >> 1;
go(v + v, tl, tm, s + '0');
go(v + v + 1, tm + 1, tr, s + '1');
}
ll mul(ll a, ll b){
return 1LL * a * b % mod;
}
ll get(string s){
ll ans = 0;
for(int i = sz(s) - 1; i >= 0; i--){
ans = mul(ans, 2);
ans += s[i] - '0';
ans %= mod;
}
return ++ans;
}
string conv(ll t){
string ret = "";
while(t){
ret += char('0' + t % 2);
t >>= 1;
}
reverse(all(ret));
return ret;
}
void solve() {
cin >> n >> k;
--k;
string t = conv(k);
reverse(all(t));
while(sz(t) < n)
t.pb('0');
reverse(all(t));
cout << get(t) << nl;
}
signed main() {
speed;
int T = 1;
// cin >> T;
while (T--)
solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |