记录编号 28462 评测结果 AAAAAAAAAA
题目名称 抗击SARS 最终得分 100
用户昵称 GravatarTruth.Cirno 是否通过 通过
代码语言 C++ 运行时间 0.004 s
提交时间 2011-10-14 19:55:47 内存使用 109.36 MiB
显示代码纯文本
#include <cstdio>
using namespace std;

double vir[22][650000]={{0}};

int main(void)
{
	freopen("sars.in","r",stdin);
	freopen("sars.out","w",stdout);
//	const double NUM=0.00001;
	double x,r,l,v,house=0,left=0,right=0;
	int i,j,num=1,c=0;
	bool flag;
	scanf("%lf %lf %lf %lf",&x,&r,&l,&v);
	vir[1][1]=x;
	for (i=1;l>=1.0;/* */num*=2,l/=2,i++/* */)
	{
		if (num>=320000)
		{
			num/=2;
			for (j=1;j<=num;j++)
				vir[i][j]=vir[i][j+num];
		}
		house=i*v;
		flag=false;
		for (j=1;j<=num;j++)
		{
			left=vir[i][j]-r;
			right=vir[i][j]+r;
			if ((house-v>=left&&house-v<=right)||(house>=left&&house<=right)||(left>=house-v&&left<=house)||(right>=house-v&&right<=house))//((house-v>=left&&house-v<=right)||(house>=left&&house<=right))
				flag=true;
			vir[i+1][j*2-1]=vir[i][j]-l;
			vir[i+1][j*2]=vir[i][j]+l;
		}
		c+=flag;
	}
	house=i*v;
	flag=false;
	for (j=1;j<=num;j++)
	{
		left=vir[i][j]-r;
		right=vir[i][j]+r;
		if ((house-v>=left&&house-v<=right)||(house>=left&&house<=right)||(left>=house-v&&left<=house)||(right>=house-v&&right<=house))//((house-v>=left&&house-v<=right)||(house>=left&&house<=right))
			flag=true;
	}
	c+=flag;
	printf("%d\n",c);
	fclose(stdin);
	fclose(stdout);
	return(0);
}