Heart Rate
Time limit2sMemory limit512 MB
Given a beat count b over p seconds, find the lower and upper bounds on the constant-interval heart rate that could produce it, plus the estimate 60b/p.
- Level
Medium4 of 10
- Topics
- Math, Implementation, Binary search, Brute force
- Solved
- No attempts yet
Problem
A common way to check your own heart rate is to put your index and middle finger on your neck next to the windpipe, count the beats you feel over 15 seconds, and multiply that count by four. The beats per minute (BPM) you get this way is only an estimate. In general, if you count beats in seconds, the BPM is .
In this problem the heart always beats at a constant interval. If is the time in seconds between one beat and the next, the Actual Beats Per Minute (ABPM) is defined as .
A measurement takes a window of exactly seconds and counts the beats that fall inside it. Even when the count is , more than one value of produces that count, so the ABPM is not determined. The ABPM values consistent with counting beats in seconds form an interval.
Input
The first line contains the number of test cases ().
Each of the next lines describes one test case. A line contains the counted number of beats () and the measuring time (), separated by a space. The value is a real number written with 4 digits after the decimal point.
Output
For each test case, print on a single line the lower endpoint of the interval of possible ABPM values, the calculated BPM , and the upper endpoint of that interval, separated by single spaces.
Print all three values rounded to 4 digits after the decimal point, padded with zeros so that exactly 4 digits follow the decimal point.