이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define modder 1000000007LL
vector<int> power2Mod;
int solve(int n, int k)
{
if (n == 0)
return 1;
if (k % 2LL) // k is odd -> left subtree
return solve(n - 1LL, (k + 1LL) / 2LL);
else
return (solve(n - 1, k / 2) + power2Mod[n - 1]) % modder;
}
signed main()
{
cin.tie(0);
ios_base::sync_with_stdio(false);
int n, k;
cin >> n >> k;
power2Mod = vector<int>(n, 1);
for (int i = 1; i < n; i++)
{
power2Mod[i] = (power2Mod[i - 1] * 2) % modder;
}
cout << solve(n, k);
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |