# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1147974 | mariza | Rack (eJOI19_rack) | C11 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
//i/o optimizations
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//data types & structures
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
#define pq priority_queue
//ds methods
#define F first
#define S second
#define pb push_back
//graph structures
typedef vector<pair<ll,ll>> graph;
typedef vector<ll> nw_graph;
typedef vector<ll> tree;
typedef pq<pair<ll,ll>> dij_q;
//constant values
const ll N=2e5+1;
const ll N3=5e3+1;
const ll N4=2e4+1;
const ll N5=1e5+1;
const ll N6=1e6+1;
const ll N8=1e8+1;
const ll INF=1e18+1;
const ll LOGN=20;
const ll LOG9=30;
const ll LOG18=60;
const ll MOD=1e9+7;
//operations
#define MID ((l+r)/2)
#define RANGE (r-l+1)
#define CEIL(a,b) (((a)/(b))+(((a)%(b))?1:0))
//output
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define ANS(ans) if(ans) YES; else NO
//math
ll mpow(ll b, ll p, ll m=MOD){ll ans=1; while(p>0){ if(p%2==1)ans*=b; b=(b*b)%m; p/=2; ans%=m;} return ans;}
#define div(a) *mpow(a,MOD-2,MOD);
#define divm(a,m) *mpow(a,m-2,m);
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (((a)*(b))/gcd(a,b))
//sortings
#define decr [](ll a, ll b){return a>b;}
int main(){
fastio;
ll n, k;
cin>>n>>k; k--;
ll ans=1;
for(ll i=0; i<min(n,60ll); i++){
if(k&(1ll<<i)) ans+=mpow(2,n-i-1);
ans%=MOD;
}
cout<<ans<<endl;
return 0;
}