记录编号 80274 评测结果 AAAAAA
题目名称 跳远 最终得分 100
用户昵称 Gravatarcstdio 是否通过 通过
代码语言 C++ 运行时间 0.002 s
提交时间 2013-11-06 22:34:31 内存使用 0.32 MiB
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
#define SIZEN 20
#define g 10.0
#define eps 1e-8
#define INF 1e18
inline double sqr(double x){
	return x*x;
}
class POINT{
public:
	double x,y;
	POINT(){x=y=0;}
	void output(void){
		cout<<x<<" "<<y;
	}
};
class TRIANGLE{
public:
	POINT u;//上顶点
	POINT l;//左顶点
	POINT r;//右顶点
	double ls;//边长
};
class FUCTION{//二次函数
public:
	double a,b,c;//三个参数
	double v;//初速度
	void resolve(POINT,POINT);
	double calc(double);
	bool above(POINT);
	void output(void){
		cout<<"y="<<a<<"x^2+"<<b<<"x+"<<c;
	}
};
double FUCTION::calc(double x){
	return a*sqr(x)+b*x+c;
}
bool FUCTION::above(POINT p){//前提是p.x在函数的定义域内
	double nowy=calc(p.x);
	if(nowy>=p.y) return true;
	return false;
}
void FUCTION::resolve(POINT ori,POINT goal){
	double temp1,temp2;
	double dx,dy;
	dx=goal.x-ori.x;
	dy=goal.y-ori.y;
	temp1=0.5*g*sqr(dx);
	temp2=dx-dy;
	if(temp2<eps){
		v=INF;
		return;
	}
	v=sqrt(temp1/temp2);
	a=-0.5*g/sqr(v);
	b=1+ori.x*g/sqr(v);
	c=ori.y-ori.x-sqr(ori.x)*0.5*g/sqr(v);
}
int n;
double V0;
TRIANGLE tri[SIZEN];
bool check_legal(int start,int end){//第start个三角形的尖蹦到第end个三角形的尖
	FUCTION f;
	f.resolve(tri[start].u,tri[end].u);
	if(f.v>V0) return false;
	int i;
	for(i=start+1;i<=end;i++){
		if(!f.above(tri[i].l)) return false;
		if(i==end) break;
		if(!f.above(tri[i].u)) return false;
	}
	return true;
}
int farest(int start){
	int i;
	if(!check_legal(start,start+1)) return 0;
	for(i=start+2;i<=n;i++){
		if(!check_legal(start,i)) return i-1;
	}
	return n;
}
void work(void){
	int i;
	for(i=1;i<n;i++) printf("%d ",farest(i));
	printf("\n");
}
void read(void){
	scanf("%d%lf",&n,&V0);
	int i;
	for(i=1;i<=n;i++){
		scanf("%lf",&tri[i].ls);
		tri[i].l=tri[i-1].r;
		tri[i].r=tri[i].l,tri[i].r.x+=tri[i].ls;
		tri[i].u.x=(tri[i].l.x+tri[i].r.x)/2;
		tri[i].u.y=tri[i].ls*sqrt(3.0)/2;
	}
}
int main(){
	freopen("jump.in","r",stdin);
	freopen("jump.out","w",stdout);
	read();
	work();
	return 0;
}