제출 #731220

#제출 시각아이디문제언어결과실행 시간메모리
731220aykhnRack (eJOI19_rack)C++14
100 / 100
10 ms7892 KiB
#include <bits/stdc++.h>

/*
    author: aykhn
    4/24/2023
*/

using namespace std;

typedef long long ll;

#define OPT ios_base::sync_with_stdio(0); \
            cin.tie(0); \
            cout.tie(0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(v) v.begin(), v.end()
#define mpr make_pair
#define pb push_back
#define ts to_string
#define fi first
#define se second
#define inf 0x3F3F3F3F
#define infll 0x3F3F3F3F3F3F3F3FLL
#define bpc __builtin_popcount
#define print(v) for(int i = 0; i < v.size(); i++) cout << v[i] << " "; cout<<endl;

const ll mod = 1000000007;
ll n, k;

int main()
{
    OPT;
    cin >> n >> k;
    k--;
    vector<ll> power(n+1, 0);

    power[0] = 1;

    for (int i = 1; i <= n; i++) power[i] = (power[i - 1] * 2) % mod;

    ll res = 1;
    for (int i = 0; i <= min(n, 62 * 1LL); i++)
    {
        if (k & (1LL << i))
        {
            res = (res + power[n - i - 1]) % mod;
        }
    }
    cout << res << endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...