10693 | 2024-04-09 18:57:14 | Ignác | Akasztós tartó | cpp17 | Accepted 100/100 | 8ms | 4208 KiB |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, k;
cin >> n >> k;
k--;
vector<bool> bin;
long long power = 2;
while (k > 0) {
bin.push_back(k % power != 0);
k -= k % power;
power *= 2;
}
bin.resize(n, 0);
long long ans = 0;
power = 1;
for (int i = n - 1; i >= 0; i--) {
ans += power * bin[i];
ans %= 1000000007;
power *= 2;
power %= 1000000007;
}
cout << ans + 1;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 20/20 | ||||||
1 | Accepted | 3ms | 1808 KiB | ||||
2 | Accepted | 3ms | 2056 KiB | ||||
3 | Accepted | 3ms | 2304 KiB | ||||
4 | Accepted | 3ms | 2556 KiB | ||||
5 | Accepted | 3ms | 2768 KiB | ||||
subtask2 | 20/20 | ||||||
1 | Accepted | 3ms | 2952 KiB | ||||
2 | Accepted | 3ms | 3156 KiB | ||||
3 | Accepted | 2ms | 3396 KiB | ||||
4 | Accepted | 2ms | 3344 KiB | ||||
5 | Accepted | 3ms | 3316 KiB | ||||
subtask3 | 60/60 | ||||||
1 | Accepted | 2ms | 3436 KiB | ||||
2 | Accepted | 3ms | 3512 KiB | ||||
3 | Accepted | 3ms | 3524 KiB | ||||
4 | Accepted | 3ms | 3772 KiB | ||||
5 | Accepted | 8ms | 4208 KiB |