View Code of Problem 32

#include<stdio.h>
#include<math.h>
typedef struct enemy{
	double x;
	double y;
	double hp;
};
int main()
{
	double a,b;
	while(scanf("%lf %lf",&a,&b)!=EOF){
	int flag=0;
	
	struct enemy e[5];
	
	for(int i=0;i<5;i++)
	{
		scanf("%lf %lf %lf",&e[i].x,&e[i].y,&e[i].hp);
	}
	float range,r;
	scanf("%lf %lf",&range,&r);
	for(int i=0;i<5;i++)
	{
		float distance=sqrt(pow(e[i].x-a,2)+pow(e[i].y-a,2));
		if(range>=distance)
		{
			double damage=r*distance*1.0;
			if(damage>=e[i].hp)
			{
				flag=1;
			}
			for(int j=0;j<5;j++)
			{
				float dis=sqrt(pow(e[j].x-a,2)+pow(e[j].y-a,2));
				if(j!=i&&dis<=range&&e[j].x*e[i].y==e[j].y*e[i].x)
				{
					flag=0;
				}
			}
			if(flag)
			{
				break;
			}
		}
	}
	if(flag){printf("Yes\n");}
	else{printf("No\n");}
}
	return 0;
	
}

Double click to view unformatted code.


Back to problem 32