现在的位置: 首页 > 综合 > 正文

HDU 4036 物理坑爹题

2013年10月11日 ⁄ 综合 ⁄ 共 2371字 ⁄ 字号 评论关闭
/*******************************************************************************
   坑爹的地方比较多,首先所有质量都是没用的,因为无摩擦力;其次坐标最好都用double表示;还有那个
土豆是的坐标是相对于第一个peak的坐标,第四貌似有土豆可以不在peak的范围内。。。以后找min/max值
还是用第一个元素做标记比较好。。。
*******************************************************************************/
#include <iostream>
#include <functional>
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <sstream>
#include <utility>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <limits>
#include <memory>
#include <string>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <set>
using namespace std;

#define LOWBIT(x) ( (x) & ( (x) ^ ( (x) - 1 ) ) )
#define CLR(x, k) memset((x), (k), sizeof(x))
#define CPY(t, s) memcpy((t), (s), sizeof(s))
#define SC(t, s) static_cast<t>(s)
#define LEN(s) static_cast<int>( strlen((s)) )
#define SZ(s) static_cast<int>( (s).size() )

typedef double LF;
typedef __int64 LL;		//VC
typedef unsigned __int64 ULL;

typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<double, double> PDD;

typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VF;
typedef vector<string> VS;

template <typename T>
T sqa(const T & x)
{
	return x * x;
}
template <typename T>
T gcd(T a, T b)
{
	if (!a || !b)
	{
		return max(a, b);
	}
	T t;
	while (t = a % b)
	{
		a = b;
		b = t;
	}
	return b;
};

const int INF_INT = 0x3f3f3f3f;
const LL INF_LL = 0x7fffffffffffffffLL;		//15f
const double oo = 10e9;
const double eps = 10e-7;
const double PI = acos(-1.0);

#define  ONLINE_JUDGE

const int MAXN = 10004;

int test, n, m, w;
struct Peak
{
	LF x, h;
}peak[MAXN];
struct Point
{
	LF x, v;
}pnt[MAXN];

void ace()
{
	int cas = 1;
	LF ans = 0;
	for (cin >> test; test--; ++cas)
	{
		cin >> n >> m >> w;
		LF maxh = peak[0].h;
		for (int i = 0; i < n; ++i)
		{
			cin >> peak[i].x >> peak[i].h;
			maxh = max(maxh, peak[i].h);
		}
		ans = sqrt(2.0 * 20 * (maxh - peak[0].h));
		for (int i = 0; i < m; ++i)
		{
			int tw;
			cin >> pnt[i].x >> pnt[i].v >> tw;
			pnt[i].x += peak[0].x;
			for (int k = 0; k < n - 1; ++k)
			{
				if (peak[k].x < pnt[i].x + eps && pnt[i].x < peak[k + 1].x)
				{
					LF dh = peak[k + 1].h - peak[k].h;
					LF dx = peak[k + 1].x - peak[k].x;
					LF ph = peak[k].h + (pnt[i].x - peak[k].x) / dx * dh;
					LF buf = pnt[i].v * pnt[i].v + 2.0 * 20 * (ph - peak[0].h);
					if (buf + eps > 0)
					{
						ans = max(ans, sqrt(buf));
					}
					break ;
				}
			}
		}
		printf("Case %d: %.2lf\n", cas, ans);
	}
	return ;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
#endif
	ace();
	return 0;
}
/*******************************************************************************
Test Data...
1
6 2 100
0 0
2 5
3 2
4 1
5 3
8 -2
2 15 100
5 11 100
*******************************************************************************/

抱歉!评论已关闭.