Car HDU - 5935
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 ;
}
Car HDU - 5935的更多相关文章
- HDU 5935 Car 【模拟】 (2016年中国大学生程序设计竞赛(杭州))
Car Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submiss ...
- HDU 5935 Car【贪心,枚举,精度】
Problem Description Ruins is driving a car to participating in a programming contest. As on a very t ...
- HDU——T 2818 Building Block
http://acm.hdu.edu.cn/showproblem.php?pid=2818 Time Limit: 2000/1000 MS (Java/Others) Memory Limi ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
- HDU 4569 Special equations(取模)
Special equations Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- HDU 4006The kth great number(K大数 +小顶堆)
The kth great number Time Limit:1000MS Memory Limit:65768KB 64bit IO Format:%I64d & %I64 ...
- HDU 1796How many integers can you find(容斥原理)
How many integers can you find Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d ...
随机推荐
- JavaBean命名规范
———————————————————————————————————————————————————————— 属性名/类型 | ...
- 【linux之文件查看,操作】
一.shell如何处理命令 1.shell会根据在命令中出现的空格字符,将命令划分为多个部分 2.判断第一个字段是内部命令还是外部命令 内部命令:内置于shell的命令(shell builtin) ...
- Codeforces Round #395 (Div. 2)(未完)
2.2.2017 9:35~11:35 A - Taymyr is calling you 直接模拟 #include <iostream> #include <cstdio> ...
- 10位时间戳转为C#格式时间
/// <summary> /// 10位时间戳转为C#格式时间 /// </summary> /// <param name=”timeStamp”></p ...
- 自己写的一个vii总结
#include<stdlib.h>#include<stdio.h>#include<unistd.h>#include<errno.h>#inclu ...
- python学习:递归列出目录里的文件
#!/usr/bin/python import os import sys def print_files(path): lsdir = os.listdir(path) d ...
- 你所有不知的margin属性
前言 致谢 本文总结于 张鑫旭老师的 CSS深入理解之margin课程,感谢张老师的辛苦付出! 难学的 CSS 作为前端狗的我们,每天都要和网页打交道.当 UI 将设计稿发给你时,CSS 的知识便显得 ...
- url路径去掉两个opencms
采用刚刚的方法安装OpenCMS之后,站点url中会存在两个opencms,造成访问url路径过长,下面讲解一种去掉两个opencms的方法. 1.去掉第一个opencms 安装时采用ROOT安装,即 ...
- 菜鸟之旅——.NET垃圾回收机制
.NET的垃圾回收机制是一个非常强大的功能,尽管我们很少主动使用,但它一直在默默的在后台运行,我们仍需要意识到它的存在,了解它,做出更高效的.NET应用程序:下面我分享一下我对于垃圾回收机制(GC)的 ...
- Yii2中后台用前台的代码设置验证码显示不出来?
我说的是直接修改advanced模板.细心人会发现模板里在contact里有,登录也想要就仿照contact中的做法.前台好了,后台登录也要验证码,就把前台代码拿过来,可惜前后台的SiteContro ...