题目

比赛的时候,队友很蛋疼地把终点直接当成 (0,0),导致wa啊wa啊wa啊~~~

刚才我写了下,开始竟然也一直wa~~~= =、

由于开始的时候以为会乘法溢出什么的用了long long..

然后又沙比般地用了%lld读数据....(靠,一开始就都用double多好...)

我竟然沙比般地忘记了蛋疼的hdoj不支持%lld..........

然后沙比般的debug了n久......

还好比赛的时候我告诉队友的是%I64,不然要是wa在这里会更蛋疼吧..............总之蛋疼..


代码:

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

#define int64 long long
#define MAXN 1010
#define MAXM 1010
#define INF 1<<30
#define g 20
int64 n, m, w;		//n 个山	
struct high
{
	int64 x, y;
}mn[MAXN];
struct potato
{
	int64 x, v, m;
}po[MAXM];

double getY(int k)	//第k个球
{
	double y;
	for(int i=0; i<n-1; i++) if(mn[i].x<=po[k].x && mn[i+1].x>=po[k].x)
	{
		return (double)(po[k].x-mn[i].x)*(mn[i+1].y-mn[i].y)/(mn[i+1].x-mn[i].x)+mn[i].y;
	}
}

double solve()
{
	double maxv2=0;		//速度最小0
	for(int i=0; i<m; i++)
	{
		double y = getY(i);
		double v = po[i].v;
		double tv2 = v*v-2*g*(mn[0].y-y);
		maxv2 = max(maxv2, tv2);
	}
	return maxv2;
}

int main()
{
	int t;	scanf("%d", &t);
	for(int T=0; T<t; T++)
	{
		printf("Case %d: ", T+1);

		scanf("%I64d%I64d%I64d", &n, &m, &w);

		int64 maxx=-INF;
		for(int i=0; i<n; i++)
		{
			scanf("%I64d%I64d", &mn[i].x, &mn[i].y);
			maxx = max(mn[i].y, maxx);
		}
		double minv2 = maxx<=mn[0].y? 0: 2*g*(maxx-mn[0].y);		//最小v2
		for(int i=0; i<m; i++)
		{
			scanf("%I64d%I64d%I64d", &po[i].x, &po[i].v, &po[i].m);
		}

		minv2 = max(solve(), minv2);
		printf("%.2lf\n", sqrt((double)minv2));
	}
}