106932024-04-09 18:57:14IgnácAkasztós tartócpp17Accepted 100/1008ms4208 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;
}
SubtaskSumTestVerdictTimeMemory
subtask120/20
1Accepted3ms1808 KiB
2Accepted3ms2056 KiB
3Accepted3ms2304 KiB
4Accepted3ms2556 KiB
5Accepted3ms2768 KiB
subtask220/20
1Accepted3ms2952 KiB
2Accepted3ms3156 KiB
3Accepted2ms3396 KiB
4Accepted2ms3344 KiB
5Accepted3ms3316 KiB
subtask360/60
1Accepted2ms3436 KiB
2Accepted3ms3512 KiB
3Accepted3ms3524 KiB
4Accepted3ms3772 KiB
5Accepted8ms4208 KiB