Submission #929493

# Submission time Handle Problem Language Result Execution time Memory
929493 2024-02-18T05:55:06 Z bambaa Rack (eJOI19_rack) C++14
100 / 100
8 ms 4240 KB
#include <bits/stdc++.h>
#include <iostream>
#include <set>
#include <cmath>
#include <iterator>
#include <vector>
 
#define ff first
#define ss second
#define mp make_pair 
#define ll long long
 
using namespace std;
int main() {

	int n;
	long long q, s = 0;
	cin >> n >> q;
	int modulo[n];
	modulo[0] = 1;
	for (int i = 1; i < n; i++){
		modulo[i] = (modulo[i - 1] * 2) % 1000000007;
	}
	bool way = true;
	for (int i = 0; i < n; i++){
		if (way == true){
			if (q % 2 == 0){
				s = (modulo[n - i - 1] + s) % 1000000007;
			} else {
				way = false;
			}
		} else {
			if (q % 2 == 1){
				s = (modulo[n - i - 1] + s) % 1000000007;
			}
		}
		q = q / 2;
	}
	s = (s + 1) % 1000000007;
	cout << s << endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 8 ms 4240 KB Output is correct