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 <iostream>
using namespace std;
typedef long long ll;
const ll my_m = 1e9 + 7;
ll szy_po(ll a, ll x)
{
if (x <= 0)
return 1;
if (x == 1)
return a;
if (x % 2 == 0)
return (szy_po(a, x / 2) * szy_po(a, x / 2)) % my_m;
return (szy_po(a, x / 2) * szy_po(a, x / 2 + 1)) % my_m;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll n, k;
ll p;
ll v = 1;
cin >> n >> k;
--k;
p = n;
while (p--)
{
if (k % 2)
v = (v * 2 + 1) % my_m;
else
v = (v * 2) % my_m;
k /= 2;
}
cout << (v - szy_po(2, n) + 1 + my_m) % my_m << "\n";
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... |