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 ...
随机推荐
- CTP期货期权交易开发
CTP交易部分接口说明 综合交易平台(Comprehensive Transaction Platform,CTP)是专门为期货公司开发的一套期货经纪业务管理系统,由交易.风险控制和结算三大系统组成. ...
- bzoj 4869: [Shoi2017]相逢是问候 [扩展欧拉定理 线段树]
4869: [Shoi2017]相逢是问候 题意:一个序列,支持区间\(a_i \leftarrow c^{a_i}\),区间求和.在模p意义下. 类似于开根操作,每次取phi在log次后就不变了. ...
- CF 246E. Blood Cousins Return [dsu on tree STL]
题意: 一个森林,求k级后代中多少种不同的权值 用set维护每个深度出现的权值 一开始一直在想删除怎么办,后来发现因为当前全局维护的东西里都是当前子树里的,如果要删除那么当前一定是轻儿子,直接清空se ...
- BZOJ 2806: [Ctsc2012]Cheat [广义后缀自动机 单调队列优化DP 二分]
2806: [Ctsc2012]Cheat 题意: 多个主串和多个询问串,每次询问将询问串分成多个连续子串,如果一个子串长度>=L且在主串中出现过就是熟悉的 如果熟悉的字符串长度>=询问串 ...
- R语言-主成分分析
1.PCA 使用场景:主成分分析是一种数据降维,可以将大量的相关变量转换成一组很少的不相关的变量,这些无关变量称为主成分 步骤: 数据预处理(保证数据中没有缺失值) 选择因子模型(判断是PCA还是EF ...
- IntelliJ IDEA环境配置
[pojie](https://www.cnblogs.com/suiyueqiannian/p/6754091.html) Error running Tomcat8: Address localh ...
- abp中文件下载,将内存数据导出到Excel并下载
1.数据导出为Excel的Stream using System; using System.Collections.Generic; using System.IO; using Abp.Colle ...
- 面试陷阱1:Integer类型的比较
public class Test01 { public static void main(String[] args) { Integer f1 = 100, f2 = 100, f3 = 150, ...
- windows上nginx的安装和配置
http://www.cnblogs.com/Li-Cheng/p/4399149.html http://www.cnblogs.com/huayangmeng/archive/2011/06/15 ...
- 《android开发艺术探索》读书笔记(十五)--Android性能优化
接上篇<android开发艺术探索>读书笔记(十四)--JNI和NDK编程 No1: 如果<include>制定了这个id属性,同时被包含的布局文件的根元素也制定了id属性,那 ...