# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
464523 | Itamar | Rack (eJOI19_rack) | C++14 | 0 ms | 0 KiB |
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>
using namespace std;
#include <algorithm>
long long a = pow(10, 9) + 7;
long long fun(long long n, long long k) {
if (k == 1) {
return 1;
}
if (k % 2 == 0) {
long long x = fun(n - 1, k / 2);
long long b = pow(2, n - 1);
return (x + b) % a;
}
else {
long long x = fun(n - 1, k / 2 + 1);
return x% a;
}
}
int main()
{
long long n, k;
cin >> n;
cin >> k;
cout << fun(n, k);
}