답안 #587264

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
587264 2022-07-01T14:46:28 Z Markomafko972 Rack (eJOI19_rack) C++14
100 / 100
7 ms 4052 KB
#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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 308 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 308 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 308 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 308 KB Output is correct
13 Correct 0 ms 340 KB Output is correct
14 Correct 1 ms 432 KB Output is correct
15 Correct 7 ms 4052 KB Output is correct