제출 #587264

#제출 시각아이디문제언어결과실행 시간메모리
587264Markomafko972Rack (eJOI19_rack)C++14
100 / 100
7 ms4052 KiB
#include <bits/stdc++.h>
#define X first
#define Y second
#define pb push_back
#define pii pair<int, int>
typedef long long ll;
using namespace std;

const int MOD = 1e9 + 7;
const ll INF = 1e18;
const int OFF = (1 << 20);

ll n, k;
int pot[1000005];

int add(int x, int y) {
	if (x+y < MOD) return x+y;
	return x+y-MOD;
}

int main () {

	cin >> n >> k;
	pot[0] = 1;
	for (int i = 1; i <= n; i++) {
		pot[i] = pot[i-1] * 2;
		pot[i] %= MOD;
	}
	k--;
	int br = 1;
	for (int i = n-1; i >= 0; i--) {
		if (k % 2 == 1) {
			br = add(br, pot[i]);
		}
		k /= 2;	
	}
	cout << br;

	return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...