View Code of Problem 32

#include <stdio.h>
#include <stdlib.h>
#include<ctype.h>
#include<string.h>
#include<math.h>
int main()
{
	typedef struct str
	{
		int x, y, hp;
	}diren;
	diren a[5];
	int x0, y0, i,j,flag,l;
	float r,s[5];
	while (scanf("%d%d", &x0,&y0)!=EOF)
	{
		for (i = 0; i < 5; i++)
		{
			scanf("%d%d%d", &a[i].x, &a[i].y, &a[i].hp);
			
			s[i] = sqrt((a[i].x - x0)*(a[i].x - x0) + (a[i].y - y0)*(a[i].y - y0));
		}
		scanf("%d%f",&l,&r);
			for (i = 0; i < 5; i++)
			{
				flag = 0;
				if (s[i] * r >= a[i].hp&&s[i] <= l)
				{
					for (j = 0; j < 5; j++)
					{
						if (i != j && s[j]<s[i]&&((a[i].y - y0)*(a[j].x - x0) == (a[j].y - y0)*(a[i].x - x0)))
						{
							if (s[j] * r < a[j].hp)
							{
								flag = 0;
								break;
							}
							else flag = 1;
						}
					}
					
				}
				if (flag == 1)
						break;
			}
			if (flag == 1)
				printf("Yes\n");
			else printf("No\n");
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 32