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;
const long long mod=1e9+7;
long long a[1000005];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long n, k, ans=0;
cin >> n >> k;
a[0]=1;
for (long long i=1; i<=n; i++)
a[i]=a[i-1]*2%mod;
for (long long i=0; i<=59; i++)
if ((k-1)&(1LL<<i))
ans=(ans+a[n-i-1])%mod;
cout << (ans+1)%mod;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |