Submission #1097238

# Submission time Handle Problem Language Result Execution time Memory
1097238 2024-10-06T14:32:09 Z vjudge1 Rack (eJOI19_rack) C++11
100 / 100
4 ms 584 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
bitset<(size_t)1e6> bin;
ll solve(const int &n, ll k) {
    if (n == 1) {
        return k;
    }
    bin.reset();
    --k;
    for (int i = n - 1; i >= 0 && k; --i) {
        if (k&1) {
            bin.set(i);
        }
        k /= 2;
    }
    ll ans = 1, base = 1;
    for (int i = 0; i < n; ++i) {
        ans = (ans + bin[i] * base)%MOD;
        base = (base * 2)%MOD;
    }
    return ans;
}
int main() {
    cin.sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    ll k;
    cin >> n >> k;
    cout << solve(n, k) << "\n";
    cout.flush();
    return EXIT_SUCCESS;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 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 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 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 0 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 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 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 0 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 348 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 4 ms 584 KB Output is correct