Submission #638516

#TimeUsernameProblemLanguageResultExecution timeMemory
638516gagik_2007Rack (eJOI19_rack)C++17
100 / 100
1 ms304 KiB
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <ctime>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <limits>
#include <iomanip>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <random>
using namespace std;

typedef long long ll;
typedef double ld;
typedef int itn;

#define ff first
#define ss second

ll ttt;
const ll INF = 1e18;
const ll SAFEINF = 1e12;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 32768;
const ll N = 2e5 + 7;
ll n, m, k;

ll binpow(ll x, ll y) {
	if (y == 0)return 1;
	if (y == 1)return x % MOD;
	if (y % 2 == 0) {
		ll vl = binpow(x, y / 2);
		return (vl * vl) % MOD;
	}
	else return (x * binpow(x, y - 1)) % MOD;
}

int main() {
	cin >> n >> k;
	ll c = n - 1;
	ll vl = 0;
	k--;
	while (c >= 0) {
		if (k % 2 != 0) {
			vl += binpow(2, c);
			vl %= MOD;
		}
		c--;
		k /= 2;
	}
	cout << ++vl << endl;
	return 0;
}

/*
4 20
2
3
2
2

*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...