hdu 5935 Car
来源:互联网 发布:马士兵java 百度云 编辑:程序博客网 时间:2024/06/06 01:18
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5935
题目描述:
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 recordN 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.
Of course, his speeding caught the attention of the traffic police. Police record
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 integersN , which is the number of the recorded positions.
The second line containsN numbers a1 , a2 , ⋯ , aN , indicating the recorded positions.
Limits
1≤T≤100
1≤N≤105
0<ai≤109
ai<ai+1
Every test case begins with an integers
The second line contains
Limits
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
136 11 21
Sample Output
Case #1: 4
Source
2016年中国大学生程序设计竞赛(杭州)
题目分析:
从后往前倒着做,最后一个时间肯定是1s
AC代码:
#include<iostream>#include<cstring>#include<cstdio>#include<cstdlib>#include<cmath>#include<algorithm>using namespace std;const long long int maxn=100005;long long int T,N,cas=1,t,t0,d0,d,time;long long int p[maxn];int main(){ scanf("%lld",&T); while(T--) { scanf("%lld",&N); for(long long int i=1;i<=N;i++) { scanf("%lld",&p[i]); } p[0]=0; t0=1; t=1; d0=p[N]-p[N-1]; for(long long int i=N-1;i>=1;i--) { d=p[i]-p[i-1]; time=(d*t0+d0-1)/d0; d0=d; t0=time; t+=time; } printf("Case #%lld: %lld\n",cas++,t); } return 0;}
0 0
- hdu 5935 Car【贪心】
- hdu 5935 Car
- HDU 5935 Car (模拟)
- hdu 5935 Car
- HDU 5935 Car 贪心
- HDU-5935-Car
- hdu 5935 Car
- HDU 5935 Car
- HDU 5935 - Car(贪心)
- hdu 5935 Car(贪心)
- Car HDU
- Car HDU
- HDU 5935 Car(模拟+精度)
- HDU 5935 Car(贪心、精度爆炸)
- HDU 5935 Car 贪心 倒推 分数
- HDU 5935 Car(思维,模拟,精度)
- HDU 5935 && 2016CCPC杭州 C: Car
- HDU-5935 Car 逆推 贪心 精度
- Linux 依赖动态库 / 静态库的动态态库 / 静态库
- Linux-2.6.31 内核移植
- CSipsimple如何添加视频通信功能
- oracle11g下载
- 第一次参加区域赛打铁记 2016.11.16
- hdu 5935 Car
- 创建JSONArray的常用四种方法
- linux开启密码登陆
- PDO连接数据库提示could not find driver解决办法
- 分解质因数: 每个非素数(合数)都可以写成几个素数(也可称为质数)相乘的形式,这几个素数就都叫做这个合数的质因数
- 过度使用DBLINK做系统集成会带来的问题
- 堆排序(优先队列)
- php分表mysql
- 树回归