답안 #642629

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
642629 2022-09-20T09:30:56 Z NewChapter Rack (eJOI19_rack) C++14
100 / 100
1 ms 212 KB
#include <bits/stdc++.h>
 
using namespace std;
 
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define vi vector<int>
#define forn(i, s, n) for(int i = s; i < n; ++i)
#define forj(j, s, n) for(int j = s; j < n; ++j)
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
 
const char* fileNameIn = "main.in";
const char* fileNameOut = "main.out";
#define files() freopen(fileNameIn, "r", stdin); freopen(fileNameOut, "w", stdout)
 
const int N = 1e9;
const int M = N + 7;
const int INF = 1e9;
typedef long long ll;

bool a[(int)1e6 + 5];

ll binpow(ll base, ll power) {
	if(power == 1) {
		return base;
	}
	if(power == 0) {
		return 1;
	}
	if(power % 2 == 0) {
		ll tmp = binpow(base, power >> 1);
		return tmp * tmp % M;
	}
	else {
		ll tmp = binpow(base, (power - 1) >> 1);
		return tmp * tmp % M * base % M;
	}
}

int main() {
	fast_io;
	int n;
	ll k;
	ll ans = 0;
	cin >> n >> k;
	k -= 1;
	int j = n - 1;
	while(k) {
		a[j--] = k % 2;
		k /= 2;
	}
	for(int i = 0; i < n; ++i) {
		if(a[i])
			ans = (ans + binpow(2, i)) % M;
	}
	ans += 1;
	ans %= M;
	cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct