RT,求助。
#include <bits/stdc++.h>
using namespace std;
struct io_Faster {
io_Faster() {
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
} IO_Faster;
typedef long long ll;
int up[25], down[25], people[25];
int main() {
int a, n, m, x;
cin >> a >> n >> m >> x;
up[1] = a;
down[1] = 0;
people[1] = a;
if (n >= 2) {
people[2] = a;
for (up[2] = down[2] = 0; up[2] <= a; up[2]++, down[2]++) {
for (int i = 3; i < n; i++) {
up[i] = up[i - 2] + up[i - 1];
down[i] = up[i - 1];
people[i] = people[i - 1] + up[i] - down[i];
}
people[n] = 0;
if (people[n - 1] == m) break;
}
}
cout << people[x] << endl;
return 0;
}