# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
464523 | 2021-08-13T10:54:09 Z | Itamar | Rack (eJOI19_rack) | C++14 | 0 ms | 0 KB |
#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); }