Submission #650269

# Submission time Handle Problem Language Result Execution time Memory
650269 2022-10-13T09:44:52 Z Kenpar Rack (eJOI19_rack) C++17
100 / 100
13 ms 8148 KB
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long
#define endl '\n'

const ll MOD = 1e9+7;
const ll INF = 1e16;
const int INT_INF = 1e9;
const ll MAX = 1e6+1;

ll pre[MAX + 5];
ll solve(ll cur, ll layer, ll ans){
	ans %= MOD;
	if(layer == -1){
		return ans;
	}

	if(cur % 2){
		return solve((cur + 1)/2, layer-1, ans);
	}

	return solve((cur + 1)/2, layer-1, ans + pre[layer]);
}
void solve(){
	ll a,b;
	cin>>a>>b;

	cout<<solve(b, a-1, 1);
}
 
 
int main()
{
	cin.tie(NULL);
	ios::sync_with_stdio(NULL);
	int t = 1;
 
	pre[0] = 1;

	for(int i = 1; i < MAX + 4; i++){
		pre[i] = (pre[i-1]*2)%MOD;
	}
	//cin >> t;
 
	while(t--){
		solve();
		cout<<endl;
	}
}
# Verdict Execution time Memory Grader output
1 Correct 7 ms 8148 KB Output is correct
2 Correct 7 ms 8020 KB Output is correct
3 Correct 7 ms 8020 KB Output is correct
4 Correct 7 ms 8020 KB Output is correct
5 Correct 8 ms 8020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 8148 KB Output is correct
2 Correct 7 ms 8020 KB Output is correct
3 Correct 7 ms 8020 KB Output is correct
4 Correct 7 ms 8020 KB Output is correct
5 Correct 8 ms 8020 KB Output is correct
6 Correct 8 ms 8036 KB Output is correct
7 Correct 8 ms 8148 KB Output is correct
8 Correct 7 ms 8020 KB Output is correct
9 Correct 8 ms 8020 KB Output is correct
10 Correct 8 ms 8060 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 8148 KB Output is correct
2 Correct 7 ms 8020 KB Output is correct
3 Correct 7 ms 8020 KB Output is correct
4 Correct 7 ms 8020 KB Output is correct
5 Correct 8 ms 8020 KB Output is correct
6 Correct 8 ms 8036 KB Output is correct
7 Correct 8 ms 8148 KB Output is correct
8 Correct 7 ms 8020 KB Output is correct
9 Correct 8 ms 8020 KB Output is correct
10 Correct 8 ms 8060 KB Output is correct
11 Correct 9 ms 8020 KB Output is correct
12 Correct 8 ms 8064 KB Output is correct
13 Correct 8 ms 8148 KB Output is correct
14 Correct 8 ms 8148 KB Output is correct
15 Correct 13 ms 8128 KB Output is correct