제출 #1341765

#제출 시각아이디문제언어결과실행 시간메모리
1341765orgiloogiiRack (eJOI19_rack)C++20
40 / 100
1 ms384 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] = 1;
    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) & (1 << i)) != 0) {
            ans += pows[n - i - 1];
            ans %= mod;
        }
    }
    cout << ans + 1 << endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...