比赛 20111012 评测结果 AAWAAWAAAA
题目名称 抗击SARS 最终得分 80
用户昵称 magic 运行时间 0.000 s
代码语言 C++ 内存使用 0.00 MiB
提交时间 2011-10-12 20:31:30
显示代码纯文本
#include<iostream>
#include<cstdio>
#define maxlong 10000000
using namespace std;
	double	x,r,lm,v;
	int maxx;
	double dist[maxlong];
	int age[maxlong];
	bool flag[100];
void dfs(int p,double x,double lon,int nam);	
void dfs(int p,double x,double lon,int nam)
{
	double x1,x2;
	int le,ri;
	le=nam*2;
	ri=nam*2+1;
	if (lon>=1)
	{
		x1=x-lon;
		x2=x+lon;
		age[le]=p+1;
		age[ri]=p+1;
		dist[le]=x1;
		dist[ri]=x2;
		dfs(p+1,x1,lon*0.5,le);
		dfs(p+1,x2,lon*0.5,ri);
	}
}	
double abss(double x);
double abss(double x)
{
	if (x<0) return (-x);else return (x);
}
int main()
{
	freopen("sars.in","r",stdin);
	freopen("sars.out","w",stdout);
	scanf("%lf%lf%lf%lf",&x,&r,&lm,&v);
	age[1]=1;
	dist[1]=x;
	dfs(1,x,lm,1);
	int n=1;
	double homel,homer;
	while (age[n]>0)
	{
		homel=float(age[n]-1)*v;
		homer=float(age[n])*v;
		if ((homel<=dist[n]&&dist[n]<=homer)||abss(homer-dist[n])<=r)
		{
			flag[age[n]]=1;
		}
		n++;
	}		
	for (int i=1;i<=100;i++)
	{
		if (flag[i]) maxx++;
	}
	printf("%d",maxx);
	return 0;
}