View Code of Problem 32

#include<stdio.h>
#include<math.h>
struct hero 
{
	int x;
	int y;
	int hp;
	double t;
	double damage;
}hero[5]; 
void main()
{
	
	int X,Y;
	while(scanf("%d %d",&X,&Y)!=EOF)
	{
		int i,j;
		for(i=0;i<5;i++)
		{
			scanf("%d %d %d",&hero[i].x,&hero[i].y,&hero[i].hp);
		}
		int l;
		double r;
		scanf("%d %lf",&l,&r);
		for(i=0;i<5;i++)
		{
			hero[i].damage=-1;
		}
		for(i=0;i<5;i++)
		{
			hero[i].t=sqrt(pow(hero[i].x-X,2)+pow(hero[i].y-Y,2));
			if(hero[i].t<=l)
			{
				hero[i].damage=r*hero[i].t;
			}
		}
		int flag,word=0;
		for(i=0;i<5;i++)
		{
			if(hero[i].hp<=hero[i].damage)
			{
				flag=0;
				for(j=0;j<5;j++)
				{
					if(i!=j&&hero[j].t<hero[i].t&&((hero[j].y-Y)*(hero[i].x-X)==(hero[i].y-Y)*(hero[j].x-X))&&hero[j].hp>hero[j].damage)
					{
						flag=1;//有其他英雄挡刀 
						break;
					}
				}
				if(flag==0)
				{
					word=1;
					printf("Yes\n");
					break;
				}
			} 
		}
		if(word==0)
		{
			printf("No\n");
		}
	}
}

Double click to view unformatted code.


Back to problem 32