You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
323 B
C++
19 lines
323 B
C++
#include <cstdio>
|
|
int p[1001], u[1001];
|
|
int main()
|
|
{
|
|
int a, n, m, x;
|
|
scanf("%d%d%d%d", &a, &n, &m, &x);
|
|
int j = 0;
|
|
while (p[n - 1] < m)
|
|
{
|
|
u[1] = p[2] = a;
|
|
u[2] = j++;
|
|
for (int i = 3; i < n; i++)
|
|
u[i] = u[i - 1] + u[i - 2],
|
|
p[i] = p[i - 1] + u[i - 2];
|
|
}
|
|
printf("%d", p[x]);
|
|
return 0;
|
|
}
|