Given integer strike times, find the smallest maximum deviation from any arithmetic progression and print it as a reduced fraction.
Medium7MathBrute forceNo attempts yetTime limit5sMemory limit512 MBThe 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 T0, T0+K, T0+2K, …, T0+(N−1)K, where T0 and K are real numbers.
No human plays a perfect rhythm. A candidate plays with error E when there are T0 and K such that ∣Ti−(T0+iK)∣≤E for every i, with the strikes numbered from 0.
Given the strike times of a candidate, find the smallest error E over all perfect rhythms the candidate could have been aiming at.
The first line has the number of test cases T. Each of the next test cases takes two lines and describes the audition of one candidate. The first line has the number of strikes N. The second line has the N strike times in milliseconds, given as integers separated by spaces in increasing order.
Limits
For each test case print one line in the form Case #x: E, where x is the test case number starting from 1 and E is the smallest possible error.
E is always a rational number, so print it as an irreducible fraction. Write E=p/q with p≥0, q≥1 and gcd(p,q)=1, then print p/q, or print only p when q is 1. Print 0 for an error of zero and 3/4 for an error of three quarters.