#include <bits/stdc++.h>
#define int long long
#define ll long long
#define pb push_back
#define fi first
#define se second
#define lf (id<<1)
#define rg ((id<<1)|1)
#define md ((l+r)>>1)
#define ld long double
using namespace std;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<int,pii> ipii;
typedef pair<pii,pii> ipiii;
const int MAXN = 2e5+10;
const int SQRT = 610;
const int MAXA = 50;
const int MOD = 1e9+7;
const int INF = 1e9+10;
const int LOG = 21;
const ld EPS = 1e-12;
int sum(int a,int b){ return (a+b)%MOD; }
int mul(int a,int b){ return a*b%MOD; }
int expo(int a, int b){
if(b==0)return 1;
int te = expo(a,b/2); te = mul(te,te);
return (b%2 ? mul(te,a) : te);
}
signed main(){
// ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n,k;cin>>n>>k;
int ans = 1;
while(true){
n--;
if(n==-1) break;
if(k%2==0){
ans = sum(ans, expo(2, n));
k /= 2;
} else {
k = (k+1)/2;
}
}
cout << ans << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |