Submission #675706

#TimeUsernameProblemLanguageResultExecution timeMemory
675706AlmaRack (eJOI19_rack)C++17
40 / 100
1 ms320 KiB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n, k;
    cin >> n >> k;
    ll pos = 0, add = n;
    bool inv = false;
    
    for (int i = 0; i < n; i++) {
        add--;
        if (inv == false) {
            if ((k & (1 << i))) {
                inv = 1;
            } else {
                pos |= (1 << add);
            }
        } else {
            if ((k & (1 << i))) {
                pos |= (1 << add);
            } else {
                inv = 1;
            }
        }
    }

    ll mod = 1e9+7;
    cout << (pos+1) % mod << '\n';

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...