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 int N = 1e6+5 , mod = 1e9+7;
long long pw[N];
long long f(long long k, int n)
{
// cerr << "f(" << k << ", " << n << ")\n";
if(n==0)
return k;
long long l = k/2 + k%2;
long long r = k/2;
if(l==r)
return (pw[n-1]+f(r, n-1))%mod;
return f(l, n-1);
}
int main()
{
int n;
long long k;
cin >> n >> k;
pw[0] = 1;
for(int i=1;i<=n;i++)
pw[i] = (pw[i-1]*2)%mod;
cout << f(k, n) << endl;
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... |