View Code of Problem 32

#include <bits/stdc++.h>
using namespace std;
#define N 6
typedef struct {
	int x,y;
	int hp;
	double d;
}Hero;
int x,y,L;
double R;
Hero hero[N];

double dis(int x1,int y1,int x2,int y2) {
	return abs(sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
} 

int main()
{
	while(cin>>x>>y) {
		for(int i=0;i<5;i++) {
			cin>>hero[i].x>>hero[i].y>>hero[i].hp;
			hero[i].d = dis(x,y,hero[i].x,hero[i].y);
		}
//		
//		for(int i=0;i<5;i++) {
//			cout<<"hero "<<i+1<<":"<<hero[i].d<<endl;
//		}
//		
		cin>>L>>R;
		int flag;
		int kill = 0;
		for(int i=0;i<5;i++) {
//			cout<<"分析 hero "<<i+1<<":"<<hero[i].d<<" "<<hero[i].d*R<<endl;
			if(hero[i].d<=L && hero[i].hp<=(R*hero[i].d)) {
				flag = 0;
				for(int j=0;j<5;j++) {
					if(i!=j && (hero[i].d>hero[j].d)&&((hero[i].x-x)*(hero[j].y-y)==(hero[i].y-y)*(hero[j].x-x))) {
						flag=1;
						break;
					}	
				}
				if(!flag)	kill = 1;
			}
		}
		if(kill)
			cout<<"Yes"<<endl;
		else 
			cout<<"No"<<endl;
	}
	return 0;
 } 

Double click to view unformatted code.


Back to problem 32