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>
#include <vector>
#include <queue>
#include <set>
using namespace std;
const long long mod = 1e9 + 7;
long long fastPow(long long x, long long p)
{
long long ans = 1, curr = x;
while(p!=0)
{
if(p%2!=0) ans = (ans*curr)%mod;
p/=2;
curr = (curr*curr)%mod;
}
return ans;
}
long long revBits(long long x, int bitCnt)
{
long long res = 0;
for(int bit = 0;bit<min(bitCnt, 63);bit++)
{
if(((x>>bit)&1)==1)
res = (res + fastPow(2, bitCnt-bit-1))%mod;
}
return res;
}
int main()
{
long long n, k;
cin >> n >> k;
cout << (revBits(k-1, n) + 1)%mod << '\n';
}
/*
5 3
5 0 1 2 5
5 2 3
4 2 3
1 4 5
3 1
2 2 1
1 2 3
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |