Files
ExerciseHub/Luogu/P1011 [NOIP 1998 提高组] 车站.cpp
2025-08-14 12:59:59 +08:00

20 lines
413 B
C++

#include <iostream>
#include <vector>
using namespace std;
int main(){
vector<int> feb;
int n, a, m, x;
cin >> a >> n >> m >> x;
feb.reserve(n);
feb.push_back(1);feb.push_back(1);
for(int i = 2; i < n; i++){
feb[i] = feb[i - 1] + feb[i - 2];
}
int b = (m - (feb[n - 4] + 1) * a) / (feb[n - 3] - 1);
int out = (feb[x - 3] + 1) * a + (feb[x - 2] - 1) * b;
cout << out << endl;
return 0;
}
//5 7 32 4