This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define int long long
#define double long double
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int N = 1e6+6;
int pw[N];
int f(int n,int k){
if(n == 0) return 1;
if(k % 2) return f(n-1,k/2+1);
return (pw[n-1] + f(n-1,k/2)) % mod;
}
void solve(){
int n,k;
cin >> n >> k;
pw[0] = 1;
for(int i=1;i<N;i++){
pw[i] = (pw[i-1] * 2) % mod;
}
cout << f(n,k) << endl;
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int t = 1;
//cin >> t;
while(t--)
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |