记录编号 28497 评测结果 AAAAAAAAAA
题目名称 抗击SARS 最终得分 100
用户昵称 Gravataryuanziyu 是否通过 通过
代码语言 C++ 运行时间 0.004 s
提交时间 2011-10-14 20:18:20 内存使用 99.45 MiB
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
double x,r,l,v;
double house;
double local,virus[20][650000];
int total=0,Times=1,w[22];
void test()
{
	bool temp=false;
	for (int i=0;i<w[Times];)
	{	
		if (house-v<virus[Times][i]-r-0.00001&&house>virus[Times][i]-r-0.00001)
			temp=true;
		if (house-v<virus[Times][i]-r-0.00001&&house>virus[Times][i]+r+0.00001)
			temp=true;
		if (house-v>virus[Times][i]-r-0.00001&&house<virus[Times][i]+r+0.00001)
			temp=true;
		if (house-v<virus[Times][i]+r+0.00001&&house>virus[Times][i]+r+0.00001)
			temp=true;
		i+=1;
	}
	if (temp)
		total++;
}

void Deliver()
{
	int num=0;
	for (int i=0;i<w[Times];i++)
	{
		virus[Times+1][i*2]=virus[Times][i]-l/2;
		virus[Times+1][i*2+1]=virus[Times][i]+l/2;
		num++;
	}
	w[Times+1]=num*2;
	Times++;
}

int main()
{
	freopen("sars.in","r",stdin);
	freopen("sars.out","w",stdout);
	cin>>x>>r>>l>>v;
	house=0;
	local=x;
	bool yes=false;
	if (house>=local-r-0.00001&&house<=local+r+0.00001)
	{
		yes=true;
	}
	house+=v;
	if (house>=local-r-0.00001&&house<=local+r+0.00001)
	{
		yes=true;
	}
	if (yes)
		total++;
	w[1]=2;
	virus[1][0]=local-l;
	virus[1][1]=local+l;
	while (l>=1)
	{
		
		house+=v;
		test();
		Deliver();
		l=l/2;
	}
	cout<<total<<endl;
	return 0;
}