Submission #1341774

#TimeUsernameProblemLanguageResultExecution timeMemory
1341774orgiloogiiRack (eJOI19_rack)C++20
40 / 100
1 ms368 KiB
#include <bits/stdc++.h>
#define int long long
#define ff first
#define ss second
using namespace std;
const int mod = 1e9 + 7;
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int n, k;
    cin >> n >> k;
    int pows[n + 1] = {0};
    pows[0] = 1ll;
    for (int i = 1;i <= n;i++) {
        pows[i] = pows[i - 1] * 2;
        pows[i] %= mod;
    }
    int ans = 0;
    for (int i = 0;i < n;i++) {
        if (((k - 1) & (1ll << i)) != 0) {
            ans += pows[n - i - 1];
            ans %= mod;
        }
    }
    cout << ans + 1 << endl;
}
//203957466
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...