Submission #742090

#TimeUsernameProblemLanguageResultExecution timeMemory
742090bogdanvladmihaiRack (eJOI19_rack)C++14
40 / 100
1 ms268 KiB
#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]; if (answer >= M) { answer -= M; } } } std::cout << answer + 1 << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...