Problem: Smart Lily

Lily is N years old. For each birthday she receives a gift. For the odd birthdays (1, 3, 5, …, n) she receives toys, and for every even (2, 4, 6, …, n) she receives money. For her second birthday she receives 10.00 BGN, and the amount is increased by 10.00 BGN for every even birthday (2 -> 10, 4 -> 20, 6 -> 30 etc.). Over the years Lily has secretly saved her money. Lily's brother ,in the years, when she receives money, takes 1.00 BGN from them. Lily has sold the toys, received over the years, every for P BGN and added the sum to the amount of saved money. With the money she wanted to buy a washing machine for X BGN. Write a program, that calculates how much money she has saved and if it is enough to buy a washing machine.

Input Data

We read from the console 3 numbers, each on separate line:

  • Age of Lily – integer number in range [1 … 77].
  • Price of the washing machine – number in range [1.00 … 10 000.00].
  • Unit price of toyinteger number in range [0 … 40].

Output Data

Print on the console one single line:

  • If Lily's money is enough:
    • Yes! {N}” – where N is the remaining money after the purchase
  • If money is not enough:
    • No! {M}” – where M is the insufficiency amount
    • Numbers N and M must be formatted to the second place after decimal point.

Sample Input and Output

Input Output Comments
10
170.00
6
Yes! 5.00

First birthday gets toy; 2nd -> 10 BGN; 3th -> toy; 4th -> 10 + 10 = 20 BGN.; 5th -> toy; 6th -> 20 + 10 = 30 BGN; 7th -> toy; 8th -> 30 + 10 = 40 BGN; 9th -> toy; 10th -> 40 + 10 = 50 .
She has saved -> 10 + 20 + 30 + 40 + 50 = 150 BGN. She sold 5 toys 6 BGN each = 30 BGN.
Her brother took 1 BGN 5 times = 5 BGN. Remain -> 150 + 30 – 5 = 175 BGN. 175 >= 170 (price of the washing machine) she managed to buy it and has left 175-170 = 5 BGN.

21
1570.98
3
No! 997.98

She has saved 550 BGN . She has sold 11 toys 3 BGN each = 33 BGN. Her brother for 10 years, has taken 1 BGN each year = 10 BGN. Remain 550 + 33 – 10 = 573 BGN.
573 < 1570.98She did not managed to buy a washing machine. The insufficiency amount is 1570.98–573 = 997.98 BGN.

results matching ""

    No results matching ""