제출 #1219593

#제출 시각아이디문제언어결과실행 시간메모리
1219593AishaRack (eJOI19_rack)C++20
0 / 100
0 ms324 KiB
#include <bits/stdc++.h>

using namespace std;

#define int long long
int mod = 1000000007;

int binpow(int n, int k) {
    if (k == 0) return 1;
    if (k % 2) return n * binpow(n, k - 1) % mod;
    int x = binpow(n, k / 2);
    return x * x % mod;
}

signed main() {
    int n, k;
    cin >> n >> k;

    vector <int> a; a.push_back(0);

    int N = binpow(2, n);
    /*
    0 -> 1 2
    1 -> 3 4
    2 -> 5 6
    3 -> 7 8
    4 -> 9 10
    5 -> 11 12
    */

    int k2 = (k + 1) / 2 - 1; int x = 1;
    for (int j = 60; j >= 0; j --) {
        if (k2 & (1 << j)) {
               // cout << j << endl;
            int y = binpow(2, j + 2);
          //  x += N / y;

            x += N * binpow(y, mod - 2) % mod;
            x %= mod;
        }
    }

    if (k % 2 == 1) {
        cout << x << endl;
    } else {
        cout << (x + N * binpow(2, mod - 2) % mod) % mod << endl;
    }

 //   for (int i = 1; i < a.size(); i ++) cout << a[i] << ' ';
    //cout << a[k] << endl;

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