比赛 20110923 评测结果 WAAWWA
题目名称 跳远 最终得分 50
用户昵称 Citron酱 运行时间 0.000 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2011-09-23 20:45:47
显示代码纯文本
#include <fstream>
#include <cmath>

#define I_F "jump.in"
#define O_F "jump.out"

const short MAXn=10;

short n, v;
short s[MAXn];
short ans[MAXn];

void Input();
void Search();
void Output();

int main()
{
	Input();
	Search();
	Output();
	return 0;
}

void Input()
{
	std::ifstream fin(I_F);
	fin>>n>>v;
	for (short i=0; i<n; fin>>s[i++]);
	fin.close();
}

void Search()
{
	double x[MAXn]={(double)s[0]/2};
	for (short i=1; i<n; i++)
		x[i]=x[i-1]+(double)(s[i-1]+s[i])/2;
	double y[MAXn];
	for (short i=0; i<n; i++)
		y[i]=s[i]*sqrt(3)/2;
	
	double t;
	bool flag;
	for (short i=0; i<n-1; i++)
		for (short j=n-1; j>i; j--)
		{
			t=(x[j]-x[i])/v;
			if (y[i]+x[j]-x[i]-5*t*t>=y[j])
			{
				flag=true;
				for (short k=i+1; k<j; k++)
					if (y[i]+x[k]-x[i]-5*((x[k]-x[i])/v)*((x[k]-x[i])/v)<=y[k])
					{
						flag=false;
						break;
					}
				if (flag)
				{
					ans[i]=j+1;
					break;
				}
			}
		}
}

void Output()
{
	std::ofstream fout(O_F);
	for (short i=0; i<n-2; fout<<ans[i++]<<' ');
	fout<<ans[n-2]<<std::endl;
	fout.close();
}