Submission #982511

#TimeUsernameProblemLanguageResultExecution timeMemory
982511NomioRack (eJOI19_rack)C++17
40 / 100
1 ms348 KiB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int mod = 1e9 + 7;
int main() {
	int n;
	ll k;
	cin >> n >> k;
	if(k == 1) {
		cout << 1 << '\n';
		return 0;
	}
	ll S = 0;
	int m = 0;
	while((1LL << m) < k) {
		m++;
	}
	while(k > 1) {
		S += (1LL << (n - m));
		S %= mod;
		k -= (1LL << (m - 1));
		while((1LL << (m - 1)) >= k) {
			m--;
		}
	}
	if(k == 1) {
		S++;
		S %= mod;
	}
	cout << S << '\n';
	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...