Drummer (Small)
Time limit5sMemory limit512 MB
Given integer strike times, find the smallest maximum deviation from any arithmetic progression and print it as a reduced fraction.
- Level
Medium7 of 10
- Topics
- Math, Brute force
- Solved
- No attempts yet
Problem
The drummer keeps the rhythm for the band. If the rhythm wobbles, the whole performance falls apart.
You are the lead singer of a popular rock band, and you have a problem. Your drummer just quit to become a professional video gamer, so you need a new one right away. There is no shortage of candidates. Your job is to pick the one who keeps the steadiest rhythm.
Each candidate auditions alone. During the audition the candidate strikes a single drum several times. In a perfect rhythm the gap between consecutive strikes is always the same, so the strike times form an arithmetic progression , where and are real numbers.
No human plays a perfect rhythm. A candidate plays with error when there are and such that for every , with the strikes numbered from 0.
Given the strike times of a candidate, find the smallest error over all perfect rhythms the candidate could have been aiming at.
Input
The first line has the number of test cases . Each of the next test cases takes two lines and describes the audition of one candidate. The first line has the number of strikes . The second line has the strike times in milliseconds, given as integers separated by spaces in increasing order.
Limits
Output
For each test case print one line in the form Case #x: E, where is the test case number starting from 1 and is the smallest possible error.
is always a rational number, so print it as an irreducible fraction. Write with , and , then print p/q, or print only p when is 1. Print 0 for an error of zero and 3/4 for an error of three quarters.