View Code of Problem 32

#include<iostream>
#include<cstdio>
#include<math.h>

using namespace std;
struct hero
{
	int a;
	int b;
	int hp;
	double k;
}h[5];

int main()
{
	int x, y, l;
	double r;
	while(cin >> x >> y)
	{
		for(int i = 0; i < 5; i++)
		{
			cin >> h[i].a >> h[i].b >> h[i].hp;
			h[i].k = (double)(h[i].b - y) / (h[i].a - x);
		}
		cin >> l >> r;
		int i;
		for(i = 0; i < 5; i++)
		{
			double d = sqrt( abs(x-h[i].a) * abs(x-h[i].a) + abs(y-h[i].b) * abs(y-h[i].b) );
			if(l >= d && d * r >= h[i].hp)
			{
				int flag = 1;
				for(int j = 0; j < 5; j++)
					if(i != j && h[i].k == h[j].k && abs(h[j].a-x) < abs(h[i].a-x))
						flag = 0;
				if(flag)
				{
					cout << "Yes" << endl;
					break;
				}
			}
		}
		if(i == 5)
			cout << "No" << endl;
	}
	return 0;
} 

Double click to view unformatted code.


Back to problem 32