답안 #896988

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
896988 2024-01-02T11:54:59 Z Jawad_Akbar_JJ Rack (eJOI19_rack) C++17
40 / 100
7 ms 8564 KB
#include <iostream>
#include <vector>


using namespace std;
#define int long long
const int N = (1<<20) + 1;

int tp[N];
int mod = 1e9 + 7;

void solve(int n,int k){
	bool right = true;

	int ans = 0;
	for (int i=1;i<=n;i++){
		bool last = 1&k;
		k >>= 1;
		if (right and last)
			right = 0;
		else if (right)
			ans += tp[n - i];
		else if (!right and last)
			ans += tp[n - i];
	}	
	cout<<ans + !right<<endl;
}

signed main(){
	tp[0] = 1;
	for (int i=1;i<N;i++)
		tp[i] = tp[i-1] * 2 % mod;
	int n,k;
	cin>>n>>k;

	if (k==tp[n])
		cout<<tp[n]<<endl;
	else
		solve(n,k);
	return 0;
	for (int i=1;i<=8;i++)
		solve(3,i);

}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 8536 KB Output is correct
2 Correct 6 ms 8540 KB Output is correct
3 Correct 6 ms 8540 KB Output is correct
4 Correct 6 ms 8540 KB Output is correct
5 Correct 6 ms 8536 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 8536 KB Output is correct
2 Correct 6 ms 8540 KB Output is correct
3 Correct 6 ms 8540 KB Output is correct
4 Correct 6 ms 8540 KB Output is correct
5 Correct 6 ms 8536 KB Output is correct
6 Correct 6 ms 8420 KB Output is correct
7 Correct 6 ms 8540 KB Output is correct
8 Correct 6 ms 8564 KB Output is correct
9 Correct 6 ms 8540 KB Output is correct
10 Correct 7 ms 8540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 8536 KB Output is correct
2 Correct 6 ms 8540 KB Output is correct
3 Correct 6 ms 8540 KB Output is correct
4 Correct 6 ms 8540 KB Output is correct
5 Correct 6 ms 8536 KB Output is correct
6 Correct 6 ms 8420 KB Output is correct
7 Correct 6 ms 8540 KB Output is correct
8 Correct 6 ms 8564 KB Output is correct
9 Correct 6 ms 8540 KB Output is correct
10 Correct 7 ms 8540 KB Output is correct
11 Incorrect 6 ms 8536 KB Output isn't correct
12 Halted 0 ms 0 KB -