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 <iostream>
#define mod 1000000007
#define int long long
using namespace std;
int p2[1000001];
int n;
static int getnum(int poz, int step, int val=0) {
if(step==n)
return val;
int len=p2[n-step-1];
if(poz>=len) {
val=(val+p2[step])%mod;
poz-=len;
}
return getnum(poz,step+1,val);
}
signed main() {
p2[0]=1;
for(int i=1; i<=1000000; i++)
p2[i]=((long long)p2[i-1]*2LL)%mod;
int k;
cin >> n >> k;
cout << 1+getnum(k-1,0) <<'\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |