| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1358300 | okahak71 | Rack (eJOI19_rack) | C++20 | 0 ms | 0 KiB |
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#ifndef ONLINE_JUDGE
#include "debug.h"
#else
#define debug(...)
#endif
#define ll long long
#define pll array<ll, 2>
#define lll array<ll, 3>
#define pb push_back
#define endl '\n'
#define all(X) X.begin(), X.end()
#define allr(X) X.rbegin(), X.rend()
using namespace std;
const ll mod = 1e9 + 7;
void _(){
auto bp = [&](ll a, ll b){
ll res = 1;
while(b){
if(b % 2) (res *= a) %= mod;
(a *= a) %= mod; b /= 2;
}
return res;
};
ll n, k, res = 1; cin >> n >> k; k--;
for(ll i = min(63ll, n); i >= 0; i--){
if(k & (1ll << i)) (res += bp(2, n - i - 1)) %= mod;
}
cout << res << endl;
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
ll t = 1; //cin >> t;
while(t--) _();
}