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. BZOJ 2006: [NOI2010]超级钢琴 [ST表+堆 | 主席树]

    题意: 一个序列,求k个不相同的长度属于\([L,R]\)的区间使得和最大 前缀和,对于每个r找最小的a[l] 然后我yy了一个可持久化线段树做法...也许会T 实际上主席树就可以了,区间k小值 然后 ...

  2. 算法&数据结构系列 -- 堆(优先队列)

    前言 话说新开的博客十分好用... 所以,我打算开一个坑,名曰[算法系列]. 什么意思--从名字泥应该就猜得出来... 废话不多说,进入正文~~ 正文 原理 首先,堆是一颗棵二叉树.. 其次,堆是一棵 ...

  3. Linux系统下LNMP一键搭建Linux、PHP、MySQL环境(适合新手搭建linux下的web生成环境)

    一. 首先要解释一下,什么是LNMP,LNMP起源于LAMP,LAMP是Linux+Apache+Mysql/MariaDB+Perl/PHP/Python的缩写,这里将Web服务端的Apache替换 ...

  4. ajax调用handler,使用HttpWebRequest访问WCF服务

    引言 随着手机及移动设备的普及,移动端的应用也进入了热潮.以前PC端的门户网站,大多也均推出了适配移动设备的网站或者APP,再差的也注册了个公众号.在移动应用开发中,目前据我所了解到的解决方案有:1. ...

  5. Git团队协作之GitFlow & SoucceTree

    GitFlow 定义了一个围绕项目发布的严格的分支模型,仍然使用中央仓库作为开发者的交互中心 GitFlow分支 Master分支 Hotfix紧急修改 Release分支 Develop开发分支 F ...

  6. python学习:函数的递归调用

    计算阶层   普通方法: -使用循环   #!/usr/bin/python   def factorial(n):     sum = 1     for i in range(1,n+1):   ...

  7. 使用CentOS7配置Squid代理

    其实之前配过一个squid,只是由于太懒,网上随便搜了一个教程,用了默认端口并且没有添加用户认证.某天不幸的被爬虫扫到,被用来发了半个月的垃圾邮件..直到有一天登录邮箱,看到了一大坨警告邮件,才意识到 ...

  8. angular-file-upload封装为指令+图片尺寸限制

    不了解angular-file-upload基础使用 请先参考http://blog.csdn.net/lai_xu/article/details/49535847 博客地址 下文如果有更好的建议请 ...

  9. Dubbo广播模式下报错:Can't assign requested address解决办法

    原因: 尝试使用Dubbo的multicast模式,发现一运行就报Can't assign requested address的错误,造成这种原因的主要是系统中开启了IPV6协议(比如window7) ...

  10. CentOs下Mongodb的下载与安装

    1.下载MongoDB(64位) http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.4.9.tgz tar zxvf mongodb-lin ...