답안 #638739

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
638739 2022-09-07T08:44:38 Z Koful123 Rack (eJOI19_rack) C++17
100 / 100
9 ms 8148 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define int long long
#define double long double
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const int N = 1e6+6;
int pw[N];

int f(int n,int k){
	if(n == 0) return 1;
	if(k % 2) return f(n-1,k/2+1);
	return (pw[n-1] + f(n-1,k/2)) % mod;
}

void solve(){

	int n,k;
	cin >> n >> k;

	pw[0] = 1;
	for(int i=1;i<N;i++){
		pw[i] = (pw[i-1] * 2) % mod;
	}

	cout << f(n,k) << endl;
}

signed main(){

	ios::sync_with_stdio(0);
	cin.tie(0);

	int t = 1;
	//cin >> t;

	while(t--)
		solve();
	
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 8020 KB Output is correct
2 Correct 9 ms 8128 KB Output is correct
3 Correct 8 ms 8148 KB Output is correct
4 Correct 8 ms 8020 KB Output is correct
5 Correct 8 ms 8132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 8020 KB Output is correct
2 Correct 9 ms 8128 KB Output is correct
3 Correct 8 ms 8148 KB Output is correct
4 Correct 8 ms 8020 KB Output is correct
5 Correct 8 ms 8132 KB Output is correct
6 Correct 8 ms 8020 KB Output is correct
7 Correct 7 ms 8148 KB Output is correct
8 Correct 7 ms 8020 KB Output is correct
9 Correct 8 ms 8028 KB Output is correct
10 Correct 9 ms 8108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 8020 KB Output is correct
2 Correct 9 ms 8128 KB Output is correct
3 Correct 8 ms 8148 KB Output is correct
4 Correct 8 ms 8020 KB Output is correct
5 Correct 8 ms 8132 KB Output is correct
6 Correct 8 ms 8020 KB Output is correct
7 Correct 7 ms 8148 KB Output is correct
8 Correct 7 ms 8020 KB Output is correct
9 Correct 8 ms 8028 KB Output is correct
10 Correct 9 ms 8108 KB Output is correct
11 Correct 8 ms 8020 KB Output is correct
12 Correct 9 ms 8132 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 8148 KB Output is correct