Of course, his speeding caught the attention of the traffic police. Police record N
positions of Ruins without time mark, the only thing they know is every position is recorded at an integer time point and Ruins started at 0
.
Now they want to know the minimum time that Ruins used to pass the last position.

, which indicates the number of test cases.
Every test case begins with an integers N
, which is the number of the recorded positions.
The second line contains N
numbers a1
, a2
, ⋯
, aN
, indicating the recorded positions.
Limits
1≤T≤100
1≤N≤105
0<ai≤109
ai
<a
i+1
3
6 11 21
废墟正在开车参加编程比赛。 由于时间非常紧张,他会在没有任何减速的情况下驾驶赛车,因此赛车的速度是非减少的实数。
当然,他的超速驾驶引起了交警的注意。 警方在没有时间标记的情况下记录了N个遗址的废墟位置,他们知道的每一个位置唯一的记录是在整数时间点记录的,废墟从0开始记录。
现在他们想知道遗迹用于通过最后位置的最短时间。
这题是个想法题,速度递增 先算出速度的最大值 速度可以为小数,
当速度不等时,可以略微的下调速度 b=temp/(t+1);
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<set>
#include<cctype>
using namespace std;
int a[];
int main() {
int t,cas=,n;
scanf("%d",&t);
while(t--) {
scanf("%d",&n);
for (int i= ; i<n ; i++)
scanf("%d",&a[i]);
long long ans=;
double b=a[n-]-a[n-];
for (int i=n- ; i>= ; i--) {
double temp=(a[i]-a[i-])*1.0;
int t=temp/b;
ans+=t;
if (temp/t!=b) {
ans++;
b=temp/(t+);
}
}
printf("Case #%d: %d\n",cas++,ans);
}
return ;
}