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;
const int MAX = 1e6 + 5, MOD = 1e9 + 7;
int n, sol;
long long k;
bool binary[MAX];
int main()
{
cin >> n >> k;
k--;
for(int i = 0; i < min(n, 64); i++){
if(k & (1LL << i)) binary[n - i - 1] = 1;
}
int pow2 = 1;
for(int i = 0; i < n; i++){
if(binary[i]) sol = (sol + pow2) % MOD;
pow2 = (pow2 * 2) % MOD;
}
cout << (sol + 1) % MOD;
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... |