[C++] 纯文本查看 复制代码 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll n, k, max, index;
vector<ll> arr;
scanf("%lld%lld", &n, &k);
if (n & 1) arr.push_back(n);
else {
arr.push_back(n / 2);
arr.push_back(n / 2);
}
for (ll i=0; i<k; ++i) {
for (ll j=0; j<arr.size(); ++j) ++arr[j];
max = -1; index = -1;
for (ll j=0; j<arr.size(); ++j) {
if (!(arr[j] & 1) && (arr[j] > max)) {
index = j;
max = arr[index];
}
}
if (index != -1) {
arr[index] /= 2;
arr.push_back(arr[index]);
}
}
max = -1;
for (ll i=0; i<arr.size(); ++i) {
if (arr[i] > max) max = arr[i];
}
printf("%lld\n", max);
} |