제출 #1268146

#제출 시각아이디문제언어결과실행 시간메모리
1268146haithamcoderRack (eJOI19_rack)C++20
100 / 100
1 ms328 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const ll LOG = 31;

#define db(x) cerr << #x << " = " << x << " | "
#define dbg(x) cerr << #x << " = " << x << "\n"

#define Algerian ios::sync_with_stdio(0);
#define OI cin.tie(NULL);

ll binexp(ll b, ll e) {
    ll res = 1;

    while (e > 0) {
        if (e & 1) res = (res * b) % MOD;

        e >>= 1;
        b = (b * b) % MOD;
    }
    
    return res;
}

int main() {
    Algerian OI

    ll n, k;
    cin >> n >> k;

    --k;
    ll res = 0;
    while (n > 0) {
        if (k & 1) {
            res = (res + binexp(2, n - 1)) % MOD;
        }

        k >>= 1;
        n--;
    }

    cout << (res + 1) % MOD << "\n";
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...