题解:P13165 [GCJ 2017 #1B] Steed 2: Cruise Control
_fallen_leaves_ · · 题解
P13165 [GCJ 2017 #1B] Steed 2: Cruise Control
题意
Annie 骑着马沿着一条单向公路行进。她位于公路的
思路
我们不需要考虑一条马追上另一条马,速度可能会改变这一条件,因为追上另一匹马的马,所用的时间肯定与追上的那匹马是时间相等,我们只要统计出所有马到
#include<bits/stdc++.h>
#define int long long
using namespace std;
int t,op=0;
signed main()
{
cin>>t;
while(t--)
{
op++;
double d;
int n;
cin>>d>>n;
double ans=0;
for(int i=1;i<=n;i++)
{
double x,y;
cin>>x>>y;
double tim=(d-x)/y;
ans=max(ans,tim);
}
printf("Case #%d: %10lf\n",op,d/ans);
}
return 0;
}