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>
#include <vector>
#include <string>
#include <set>
#include <cmath>
#include <tuple>
using namespace std;
/*long long int power(long long int n, int k)
{
long long int vys = 1;
for (int i = 0; i < k; i++)
{
vys = (vys * (n - i)) / (i + 1);
}
return vys;
}*/
long long int power(long long int b, long long int p, long long int mod)
{
long long int vys = 1;
for (long long int i = 0; i < p; i++)
{
vys = vys * b;
vys %= mod;
}
return vys;
}
int main()
{
/*for (int i = 0; i < 10; i++)
{
std::cout << "Hello Flash!\n";
}*/
long long int n;
long long int k;
cin >> n;
cin >> k;
const long long int mod = 1e9 + 7;
k -= 1;
long long int i = n - 1;
long long int vys = 1;
while (i >= 0)
{
if (k % 2 !=0)
{
vys = (vys + power(2, i, mod)) % mod;
}
k = k / 2;
i -= 1;
}
cout << vys % mod << endl;
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... |