Submission #929497

# Submission time Handle Problem Language Result Execution time Memory
929497 2024-02-18T05:59:32 Z hngr Rack (eJOI19_rack) C++14
100 / 100
1 ms 600 KB
#include <iostream>
#include <vector>
#include <set>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#define int long long 
const int mod = 1e9+7;
const int N = 1e6+7;
bool a[N + 5];
using namespace std;
int build(int b, int p) {
	if(p == 1) {
		return b;
	}
	if(p == 0) {
		return 1;
	}
	if(p % 2 == 0) {
		int tmp = build(b, p >> 1);
		return tmp * tmp % mod;
	}
	else {
		int tmp = build(b, (p - 1) >> 1);
		return tmp * tmp % mod * b % mod;
	}
}
 
int32_t main() {
	int n;
	int k;
	int ans = 0;
	cin >> n >> k;
	k -= 1;
	int j = n - 1;
	while(k) {
		a[j--] = k % 2;
		k /= 2;
	}
	for(int i = 0; i < n; ++i){
		if(a[i])
			ans = (ans + build(2, i)) % mod;
	}
	ans += 1;
	ans %= mod;
	cout << ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 600 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct