hdu 5112 (2014北京现场赛 A题)
2024-10-02 12:57:09
给出某个时刻对应的速度 求出相邻时刻的平均速度 输出最大值
Sample Input
2
3 // n
2 2 //t v
1 1
3 4
3
0 3
1 5
2 0
Sample Output
Case #1: 2.00
Case #2: 5.00
# include <iostream>
# include <cstdio>
# include <cstring>
# include <algorithm>
# include <string>
# include <cmath>
# include <queue>
# include <list>
# define LL long long
using namespace std ; struct point
{
int t ;
int v ;
}a[]; bool cmp(point x , point y)
{
return x.t < y.t ;
} int main()
{
//freopen("in.txt","r",stdin) ;
int T ;
scanf("%d" , &T) ;
int Case = ;
while(T--)
{
int n , i ;
Case++ ;
double MAX = ;
scanf("%d" , &n) ;
for (i = ; i < n ; i++)
scanf("%d %d" , &a[i].t , &a[i].v) ;
sort(a , a+n , cmp) ;
for (i = ; i < n- ; i++)
{
double ans = fabs((a[i+].v - a[i].v)*1.0/(a[i+].t - a[i].t)*1.0) ;
if (ans > MAX)
MAX = ans ;
}
printf("Case #%d: %.2lf\n" , Case , MAX) ; } return ;
}
最新文章
- centos 6.5 升级php
- ToolWindow工具类
- IIS does not list a website that matches the launch url
- 【CodeForces 625A】Guest From the Past
- HttpClient 操作总结
- [BZOJ 1081] [SCOI2005] 超级格雷码 【找规律】
- 7 Ways to earn money on programming(转)
- 【0-1 背包模板】 poj 3624
- python+selenium自动化软件测试(第13章):selenium面试题
- centos6.9(Linux系统)安装VMware tools教程
- spring+myBatis 配置多数据源,切换数据源
- Windows 修改域用户账户密码
- OpenStack 安装:neutron服务
- 面象对象设计原则之七:合成复用原则(Composition/Aggregate Reuse Principle, CARP)
- NB-IoT协议及其PSM
- 使用spring的aop对Struts2的Action拦截后出现依赖注入为空问题
- DOS 格式化日期时间输出
- 获取windows鼠标的当前坐标
- Linux gcc编译参数
- 关于office word 应用程序下载配置