Lamps
Time limit1sMemory limit1024 MB
Given the daily hours a lamp is on and the electricity price, find the first day the low-energy lamp's total cost drops below the incandescent bulb's.
- Level
Easy2 of 10
- Topics
- Simulation, Math
- Solved
- No attempts yet
Problem
The use of incandescent bulbs is about to be phased out in the EU, but low-energy lamps can already pay off. Write a program that, given how many hours a lamp is on each day and the electricity price, computes after how many days the total cost (lamp purchases plus electricity cost) of the low-energy lamp is first lower than that of the incandescent bulb.
For simplicity, assume every lamp lasts exactly its stated lifetime. So one incandescent bulb is enough to keep the lamp on for 1000 hours, but for 1001 hours you must buy another bulb, because the first one burns out after 1000 hours.
The electricity cost K for keeping the lamp on for H hours is computed with where E is the lamp's power in watts and P is the electricity price in öre/kWh.
In all test cases, only one low-energy lamp needs to be bought. The low-energy lamp is therefore cheaper even before it has to be replaced.
Input
The input is one line with two integers: (), the number of hours per day the lamp is on, and (), the electricity price.
Output
Print the number of days after which the low-energy lamp is cheaper than the incandescent bulb.
Hint
After 149 days, the total cost with incandescent bulbs is 71.32840 kronor (of which 10 kronor is purchase cost, since one bulb has to be replaced once). With the low-energy lamp, it is 71.24354 kronor (of which 60 kronor is purchase cost).