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 endl '\n'
#define ll long long
#define pll pair<ll, ll>
#define mod 1000000007
ll power(ll x, ll y)
{
if (y == 0) return 1;
ll k = power(x, y/2);
if (y%2==0){
return (k*k)%mod;
}
else {
return (((k*k)%mod)*x)%mod;
}
}
int main()
{
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll n, k, num = 1;
cin>>n>>k;
for (ll i = n-1; i>=0; i--){
if (k%2==0){
ll x = power(2, i);
num += x;
num %= mod;
k /= 2;
}
else {
k = (k + 1)/2;
}
}
cout<<num;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |