Submission #638516

# Submission time Handle Problem Language Result Execution time Memory
638516 2022-09-06T10:23:32 Z gagik_2007 Rack (eJOI19_rack) C++17
100 / 100
1 ms 304 KB
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <ctime>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <limits>
#include <iomanip>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <random>
using namespace std;

typedef long long ll;
typedef double ld;
typedef int itn;

#define ff first
#define ss second

ll ttt;
const ll INF = 1e18;
const ll SAFEINF = 1e12;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 32768;
const ll N = 2e5 + 7;
ll n, m, k;

ll binpow(ll x, ll y) {
	if (y == 0)return 1;
	if (y == 1)return x % MOD;
	if (y % 2 == 0) {
		ll vl = binpow(x, y / 2);
		return (vl * vl) % MOD;
	}
	else return (x * binpow(x, y - 1)) % MOD;
}

int main() {
	cin >> n >> k;
	ll c = n - 1;
	ll vl = 0;
	k--;
	while (c >= 0) {
		if (k % 2 != 0) {
			vl += binpow(2, c);
			vl %= MOD;
		}
		c--;
		k /= 2;
	}
	cout << ++vl << endl;
	return 0;
}

/*
4 20
2
3
2
2

*/
# 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 0 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 0 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 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 300 KB Output is correct
10 Correct 0 ms 304 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 0 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 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 300 KB Output is correct
10 Correct 0 ms 304 KB Output is correct
11 Correct 0 ms 296 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct