#P13303. [GCJ 2013 Finals] Drummer
[GCJ 2013 Finals] Drummer
题目描述
The drummer has a very important role in any band -- keeping the rhythm. If the drummer's rhythm is uneven, it can ruin the entire performance.
You are the lead singer of a very popular rock band, and you have a bit of a problem. Your drummer has just quit the band to become a professional video gamer. You need to find a new drummer immediately. Fortunately, there is no shortage of candidates. Everyone wants a chance to join your band. Your task is to find the best drummer among the candidates, and you want the person who can keep the most consistent rhythm.
Your plan is as follows. You will ask each candidate to audition individually. During the audition, the candidate will play one drum by striking it with a drum stick several times. Ideally, the time difference between consecutive strikes should be exactly the same, producing a perfect rhythm. In a perfect rhythm, the drum strikes will have time stamps that follow an arithmetic progression like this: , , , , .
In real life, of course, it is nearly impossible for a human to produce a perfect rhythm. Therefore, each candidate drummer will produce a rhythm that has an error , such that each differs by at most from some perfect rhythm. Given a candidate's sequence of drum strikes, find the smallest possible among all perfect rhythms that the candidate might have been trying to play.
输入格式
The first line of the input gives the number of test cases, . test cases follow. Each one consists of two lines and represents the audition of one candidate. The first line contains a single integer -- . The next line contains integers separated by spaces -- the time stamps, in milliseconds, of the drum strikes played by the candidate. The time stamps are in increasing order.
输出格式
For each test case, output one line containing "Case #x: ", where is the case number (starting from 1) and is the smallest among all possible numbers that describe the error of the candidate's drum strike sequence.
Your answer will be considered correct if it is within an absolute or relative error of of the correct answer.
3
2
10 70
4
0 10 19 30
6
2 5 10 15 20 24
Case #1: 0
Case #2: 0.5
Case #3: 0.75
提示
Limits
Small dataset (9 Pts, Test set 1 - Visible)
- Time limit:
606 seconds.
Large dataset (20 Pts, Test set 2 - Hidden)
- Time limit:
12012 seconds. - For 90% of the test cases,
- For all test cases,