Paying Off the Debt
InterviewTime limit2sMemory limit128 MB
Simulate monthly interest rounded to the cent with a fixed payment to count months until the debt clears or report impossible.
- Level
Easy3 of 10
- Topics
- Simulation
- Solved
- No attempts yet
Problem
Sangkeun borrowed B dollars from Sunyoung. Now it is time to pay her back.
At the start of every month, interest equal to R percent of what Sangkeun still owes is added to the debt. At the end of every month he earns M dollars from tutoring and pays that much to Sunyoung.
Sangkeun borrows no more money from Sunyoung, he works no job other than tutoring, and his tutoring pay never rises.
Write a program that finds how many months it takes him to pay the debt off.
Interest is rounded to the nearest cent. One dollar is 100 cents, a leftover of 0.5 cent or more rounds up to 1 cent, and anything smaller is dropped.
Input
The input holds several test cases. The first line gives the number of test cases, which is at most 1000.
Each test case is one line with R, B and M separated by spaces. All three are real numbers written with two digits after the decimal point, and , .
Output
For each test case, print on its own line how many months it takes to pay the debt off. If the debt cannot be cleared within 1200 months, print impossible.