Problem Name: 2 AD-HOC - beecrowd | 2568

Problem Link:



By Gabriel Poesia, UFMG BR 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?




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).




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



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;
			soma += X;

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


Copy The Code & Try With Live Editor


1 10 5 3




#2567 Beecrowd Online Judge Solution 2567 Virus Solution in C, C++, Java, Js and Python
#2569 Beecrowd Online Judge Solution 2569 The 7 x 1 Witch Solution in C, C++, Java, Js and Python