kilonova/390/solutie.cpp
2025-05-08 18:42:16 +03:00

18 lines
254 B
C++

#include <fstream>
using namespace std;
ifstream fin("planta.in");
ofstream fout("planta.out");
int main() {
int d,a,b,n,i;
fin >> d >> a >> b >> n;
int z = n / 2;
d = d + a * z - b * z;
if (n % 2 == 1) {
d = d + a;
}
fout << d;
return 0;
}