Submission #465240

# Submission time Handle Problem Language Result Execution time Memory
465240 2021-08-15T12:20:25 Z Alen777 Rack (eJOI19_rack) C++14
100 / 100
18 ms 15564 KB
#include <iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;

#define ll long long
#define ull unsigned ll
#define pb push_back
#define mpr make_pair
#define lb lower_bound
#define ld long double
#define ub upper_bound

ll n, k;
vector<ll> ast;
ll mod = 1e9 + 7;

ll rec(ll n, ll k) {
    if (n == 0) {
        return 1;
    } if (k % 2LL) {
        return rec(n - 1LL, (k + 1LL) / 2LL);
    }
    else {
        return (rec(n - 1LL, k / 2LL) + ast[n - 1]) % mod;
    }
}

void solve() {
    cin >> n >> k;
    vector<ll> x(n, 1);
    ast = x;
    for(int i = 1; i < n; i++) {
        ast[i] = (ast[i - 1] * 2) % mod;
    }
    cout << rec(n, k) << endl;
}

int main() {
    /*cout.setf(ios::fixed | ios::showpoint);
    cout.precision(6);*/
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve();
    return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 308 KB Output is correct
14 Correct 2 ms 1100 KB Output is correct
15 Correct 18 ms 15564 KB Output is correct