Problem Description
Ruins is driving a car to participating in a programming contest. As on a very tight schedule, he will drive the car without any slow down, so the speed of the car is non-decrease real number.

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.

 
Input
First line contains an integer T

, 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<ai+1

 
Output
For every test case, you should output 'Case #x: y', where x indicates the case number and counts from 1 and y is the minimum time.
 
Sample Input
1
3
6 11 21
 
Sample Output
Case #1: 4
 

废墟正在开车参加编程比赛。 由于时间非常紧张,他会在没有任何减速的情况下驾驶赛车,因此赛车的速度是非减少的实数。

当然,他的超速驾驶引起了交警的注意。 警方在没有时间标记的情况下记录了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 ;
}
 

Car HDU - 5935的更多相关文章

  1. HDU 5935 Car 【模拟】 (2016年中国大学生程序设计竞赛(杭州))

    Car Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submiss ...

  2. HDU 5935 Car【贪心,枚举,精度】

    Problem Description Ruins is driving a car to participating in a programming contest. As on a very t ...

  3. HDU——T 2818 Building Block

    http://acm.hdu.edu.cn/showproblem.php?pid=2818 Time Limit: 2000/1000 MS (Java/Others)    Memory Limi ...

  4. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  5. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  6. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  7. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  8. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

  9. HDU 1796How many integers can you find(容斥原理)

    How many integers can you find Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d ...

随机推荐

  1. JSP基础篇

    JSP可以认为是加上了Java代码块的HTML文件,常常和CSS,JS结合使用,下面是一个JSP的基本的例子. <%@ page language="java" conten ...

  2. 洛谷 [P1402] 酒店之王

    有两个约束条件的二分图匹配 我们回忆一下二分图匹配的匈牙利算法的具体流程,它是通过寻找增广路来判断最大匹配数的,我们再观察一下题目中的两个条件,只有两个条件都满足,才算找到一条增广路,所以我们可以分别 ...

  3. HDU 3944 DP? [Lucas定理 诡异的预处理]

    DP? Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 128000/128000 K (Java/Others)Total Subm ...

  4. 【模板小程序】求第n个质数

    #include <iostream> #include <vector> using namespace std; int nth_prime(int n) { vector ...

  5. 一、爬虫的基本体系和urllib的基本使用

    爬虫 网络是一爬虫种自动获取网页内容的程序,是搜索引擎的重要组成部分.网络爬虫为搜索引擎从万维网下载网页.一般分为传统爬虫和聚焦爬虫. 爬虫的分类 传统爬虫从一个或若干初始网页的URL开始,获得初始网 ...

  6. S5PV210中断处理

    _start: 1.设置栈空间:防止之前的UBOOT代码被覆盖,应为c中需要栈空间 ldr sp, =0x40010000 2.设置CPSR的I,F位,A8打开IRQ,FIQ中断: mov r0, # ...

  7. 调试 smallcorgi/Faster-RCNN_TF 的demo过程遇到的问题

    最近在调试faster R-CNN时,遇到了各种各样的问题.使用的算法库为https://github.com/smallcorgi/Faster-RCNN_TF 注:本文使用的是通过virtuale ...

  8. OpenCV亚像素角点cornerSubPixel()源代码分析

    上一篇博客中讲到了goodFeatureToTrack()这个API函数能够获取图像中的强角点.但是获取的角点坐标是整数,但是通常情况下,角点的真实位置并不一定在整数像素位置,因此为了获取更为精确的角 ...

  9. 如何让div水平居中呢?

    一百度div居中,多数都是一个答案,但是有时候这种方法并不是万能的...不废话,将我知道的方法都列举一下好了,随时更新. 1.设置width值,指定margin-left和margin-right为a ...

  10. 【BZOJ1095】 Hide 捉迷藏

    Time Limit: 4000 ms   Memory Limit: 256 MB Description 捉迷藏 Jiajia和Wind是一对恩爱的夫妻,并且他们有很多孩子.某天,Jiajia.W ...