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>
const int M = 1e9 + 7;
int main() {
int N;
int64_t K;
std::cin >> N >> K;
K--;
std::vector<int> pow(63, 1);
for (size_t i = 1; i < pow.size(); i++) {
pow[i] = pow[i - 1] + pow[i - 1];
if (pow[i] >= M) {
pow[i] -= M;
}
}
int answer = 0;
for (int i = 0; i < 63; i++) {
if ((K & (1LL << (int64_t)i)) > 0) {
answer += pow[N - i - 1];
}
}
std::cout << answer + 1 << "\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... |