Submission #764659

# Submission time Handle Problem Language Result Execution time Memory
764659 2023-06-23T18:39:00 Z Gabi88 Rack (eJOI19_rack) C++14
100 / 100
8 ms 468 KB
#include<bits/stdc++.h>
using namespace std;

#define LL long long

const LL mod = 1000000007;
LL n, k, br = 0, tmp = 1;

int main(){
	ios_base::sync_with_stdio(false); cin.tie(0); cin >> n >> k; k--;
	vector<bool> v={};
	while(k > 0){ v.push_back(k%2); k /= 2; }
	while(v.size() < n) v.push_back(0);
	reverse(v.begin(), v.end());
	for(int i=0; i<n; i++){
		if (v[i]){ br += tmp; br %= mod; }
		tmp *= 2; tmp %= mod;
	}
	cout << (br+1) % mod; return 0;
}

Compilation message

rack.cpp: In function 'int main()':
rack.cpp:13:17: warning: comparison of integer expressions of different signedness: 'std::vector<bool>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   13 |  while(v.size() < n) v.push_back(0);
      |        ~~~~~~~~~^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 320 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 316 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 8 ms 468 KB Output is correct