답안 #827875

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
827875 2023-08-16T21:17:37 Z ZeroCool Rack (eJOI19_rack) C++14
100 / 100
9 ms 8132 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define mp make_pair
#define pb push_back

using ll = long long;
using ld = long double;


void solve(int T);
void pre();

const int mxn = 1e6 + 5;
const int SQRT = 500;
const int LOG = 20;
const int inf = 1e18;
const int mod = 1e9 + 7;
const ld eps = 1e-9;

int32_t main(){
	pre();
	int tt = 1;
	//cin>>tt;
	for(int i = 1;i<=tt;i++)solve(i);
    return 0;
}

int p[mxn+1];

void pre(){
	#ifdef ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);
	#endif
	p[0] = 1;
	for(int i = 1;i<=mxn;i++){
		p[i] = (2 * p[i-1]) % mod;
	}
}

void solve(int T){
	int n,k;
	cin>>n>>k;

	int ans = 1;

	for(int i = n-1;i>=0;i--){
		if(k % 2 == 0){
			ans += p[i];
			ans %= mod;
		}
		else {
			k++; 
		}
		k /= 2;
	}

	cout<<ans<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 8020 KB Output is correct
2 Correct 7 ms 8128 KB Output is correct
3 Correct 7 ms 8120 KB Output is correct
4 Correct 7 ms 8084 KB Output is correct
5 Correct 7 ms 8132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 8020 KB Output is correct
2 Correct 7 ms 8128 KB Output is correct
3 Correct 7 ms 8120 KB Output is correct
4 Correct 7 ms 8084 KB Output is correct
5 Correct 7 ms 8132 KB Output is correct
6 Correct 7 ms 8128 KB Output is correct
7 Correct 7 ms 8084 KB Output is correct
8 Correct 7 ms 8124 KB Output is correct
9 Correct 7 ms 8020 KB Output is correct
10 Correct 7 ms 8012 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 8020 KB Output is correct
2 Correct 7 ms 8128 KB Output is correct
3 Correct 7 ms 8120 KB Output is correct
4 Correct 7 ms 8084 KB Output is correct
5 Correct 7 ms 8132 KB Output is correct
6 Correct 7 ms 8128 KB Output is correct
7 Correct 7 ms 8084 KB Output is correct
8 Correct 7 ms 8124 KB Output is correct
9 Correct 7 ms 8020 KB Output is correct
10 Correct 7 ms 8012 KB Output is correct
11 Correct 7 ms 8120 KB Output is correct
12 Correct 7 ms 8056 KB Output is correct
13 Correct 7 ms 8020 KB Output is correct
14 Correct 7 ms 8020 KB Output is correct
15 Correct 9 ms 8020 KB Output is correct