题目链接:hdu 5078 Osu!
题面:

2 5 2 1 9 3 7 2 5 9 0 6 6 3 7 6 0 10 11 35 67 23 2 29 29 58 22 30 67 69 36 56 93 62 42 11 67 73 29 68 19 21 72 37 84 82 24 98
9.2195444573 54.5893762558HintIn memory of the best osu! player ever Cookiezi.
题意:就求最大值,开始还以为贪心,直接暴力就好了。
代码:
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
long long int squared_dis(long long int x1,long long int y3,long long int x2,long long int y2)
{
return (x1-x2)*(x1-x2)+(y3-y2)*(y3-y2);
}
long long int store_x[1005],store_y[1005],t[1005];
int main()
{
int tt,n;
cin>>tt;
while(tt--)
{
double maxx=0;
cin>>n;
double tmp;
for(int i=0;i<n;i++)
{
cin>>t[i]>>store_x[i]>>store_y[i];
}
for(int i=0;i<n-1;i++)
{
for(int j=i+1;j<n;j++)
{
if(t[i]!=t[j])
tmp=sqrt(1.0*squared_dis(store_x[i],store_y[i],store_x[j],store_y[j]))/abs(t[i]-t[j]);
if(tmp>maxx)
maxx=tmp;
}
}
cout<<fixed<<setprecision(10)<<maxx<<endl;
}
return 0;
} 原文地址:http://blog.csdn.net/david_jett/article/details/45652071