Submission #467223

# Submission time Handle Problem Language Result Execution time Memory
467223 2021-08-22T05:52:10 Z syrtin Rack (eJOI19_rack) C++17
100 / 100
5 ms 1228 KB
/*author:	syrtin*/
#include <bits/stdc++.h>

#define pb push_back
#define all(v) v.begin(),v.end()
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef pair<long long, long long> pll;
typedef pair < int, int > pii;
typedef vector<int> vi;
typedef vector<long long> vll;

const int N = 1e6 + 1;
const ll MOD = 1e9 + 7;
const int inf = int(1e9);
const ll INF = ll(1e16);

bool j[N];
ll n, k;
void go() {
	if(k == 1)return;
	for(int i = 0; i < n; i++) {
		if((1ll << i) * 2 >= k) {
			k -= (1ll << i), j[n - 1 - i] = 1;
			go();
			return;
		}
	}
}
void SOLVE(/*WATLE*/) {
	cin >> n >> k;
	memset(j, 0, sizeof j);
	go();
	ll pl = 1, ans = 1;
	for(int o = 0; o < n; o++){
		if(j[o])ans += pl, ans %= MOD;
		pl *= 2;
		pl %= MOD;
	}
	cout << ans;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
    int times = 1;
	//cin >> times;
    for(int i = 1; i <= times; i++) {
        //cout << "Case #" << t << ": ";
        SOLVE();
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1228 KB Output is correct
2 Correct 1 ms 1228 KB Output is correct
3 Correct 1 ms 1228 KB Output is correct
4 Correct 1 ms 1228 KB Output is correct
5 Correct 1 ms 1228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1228 KB Output is correct
2 Correct 1 ms 1228 KB Output is correct
3 Correct 1 ms 1228 KB Output is correct
4 Correct 1 ms 1228 KB Output is correct
5 Correct 1 ms 1228 KB Output is correct
6 Correct 1 ms 1228 KB Output is correct
7 Correct 1 ms 1228 KB Output is correct
8 Correct 1 ms 1228 KB Output is correct
9 Correct 1 ms 1228 KB Output is correct
10 Correct 1 ms 1228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1228 KB Output is correct
2 Correct 1 ms 1228 KB Output is correct
3 Correct 1 ms 1228 KB Output is correct
4 Correct 1 ms 1228 KB Output is correct
5 Correct 1 ms 1228 KB Output is correct
6 Correct 1 ms 1228 KB Output is correct
7 Correct 1 ms 1228 KB Output is correct
8 Correct 1 ms 1228 KB Output is correct
9 Correct 1 ms 1228 KB Output is correct
10 Correct 1 ms 1228 KB Output is correct
11 Correct 1 ms 1216 KB Output is correct
12 Correct 1 ms 1228 KB Output is correct
13 Correct 2 ms 1228 KB Output is correct
14 Correct 1 ms 1228 KB Output is correct
15 Correct 5 ms 1228 KB Output is correct