이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using i64 = long long;
constexpr int P = 1000000007;
constexpr i64 inf = 2e18;
int norm(int x) {
if (x < 0) x += P;
if (x >= P) x += P;
return x;
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
i64 n, k;
std::cin >> n >> k;
k--;
std::vector<i64> mpw(n + 1, 1), pw(n + 1, 1);
for (int i = 1; i <= n; i++) {
mpw[i] = mpw[i - 1] * 2 % P;
pw[i] = std::min(pw[i - 1] * 2, inf);
}
int ans = 0;
for (int i = 0; i < n; i++) {
if (k >= pw[n - i - 1]) {
ans = norm(ans + mpw[i]);
k -= pw[n - i - 1];
}
}
std::cout << norm(ans + 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... |