## Algorithm

Problem Name: 2 AD-HOC - beecrowd | 2568

# Actions

By Gabriel Poesia, UFMG Brazil

Timelimit: 1

Ada is an investor in a very unstable and high-risk business: NlogNintendo shares. However, because she has great sympathy for the beautiful-horizontina company, Ada continues to invest anyway.

However, instability sometimes makes it difficult for her to do her long-term portfolio planning. In order to help her, she has hired you to make a program that predicts the value of NlogNintendo. Ada has registered that on D day, a stock NlogNintendo was worth I real. Besides, at the beginning of even days, the stock price rises X reais compared to the price at the end of the previous day. On odd days, the stock price already starts with a real X value below the value at the end of the day. And now? Can you help her know what the stock price will be in F days?

## Input

The input is composed of a line containing 4 integers separated by space: D (1 ≤ D ≤ 365) (the day Ada registered the price of the NlogNintendo stock), I (XI ≤ 1000) (the initial price recorded Of the stock), X (1 ≤ X I) (the daily stock price change) and F (1 ≤ F ≤ 365) (the number of days in the future that your program should predict the share price).

## Output

The output should contain a line with a single integer: the expected price of the F share days after the day the initial price was recorded.

 Input Samples Output Samples 1 10 5 3 15

## Code Examples

### #1 Code Example with C Programming

```Code - C Programming```

``````
#include <stdio.h>

int main (void)
{

int D, I, X, F;

scanf("%d %d %d %d", &D, &I, &X, &F);

int soma = I;

for (int i = D + 1; i  < = D + F; i++)
if (i % 2 != 0)
soma -= X;
else
soma += X;

printf("%d\n", soma);

}

``````
Copy The Code &

Input

cmd
1 10 5 3

Output

cmd
15