Problem: Back to the Past

Ivancho is 18 years old and receives an inheritance that consists of X money and time machine. He decides to return to 1800, but does not know if money will be enough to live without working. Write a program that calculates if Ivancho will have enough money to not have to work until the given year. Assuming that for every even (1800, 1802, etc.) year he will spend 12 000 dollars. For every odd (1801, 1803, etc.) he will spend 12 000 + 50 * [the age he will have reached in the given year].

Input Data

The input is read from the console and contains exactly 2 lines:

  • Inherited money – a real number in the range [1.00 … 1 000 000.00].
  • Year, until to live(inclusive) – integer number in the range [1801 … 1900].

Output Data

Print on the console 1 line. Sum must be formated to the second decimal point:

  • If money is enough:
    • Yes! He will live a carefree life and will have {N} dollars left.“ – when N is money, which will remain.
  • If money is NOT enough:
    • He will need {М} dollars to survive.“ – where M is sum, which is NOT enough.

Sample Input and Output

Input Output Explanations
50000
1802
Yes! He will live a carefree life and
will have 13050.00 dollars left.

1800 → even
        → Spend 12000 dollars
        → Remain 50000 – 12000 = 38000
1801 → odd
        → Spend 12000 + 19*50 = 12950 dollars
        → Remain 38000 – 12950 = 25050
1802 → even
        → Spend 12000 dollars
        → Remain 25050 – 12000 = 13050

100000.15
1808
He will need 12399.85 dollars
to survive.

1800 → even
        → Remain 100000.15 – 12000 = 88000.15
1801 → odd
        → Remain 88000.15 – 12950 = 75050.15

1808 → odd → -399.85 - 12000 = -12399.85
12399.85 is not enough

results matching ""

    No results matching ""