View Code of Problem 32

#include<bits/stdc++.h>
#define INF 0x3f3f3f
using namespace std;
struct node{
	int x,y,hp;
	double k,l;
};
int x,y,L;
double ak(int x1,int y1){
	if(x1-x==0)return INF;
	return (double(y1)-y)/(x1-x);
}
double al(int x1,int y1){
	return sqrt((double(y1)-y)*(double(y1)-y)+(double(x1)-x)/(double(x1)-x));
}
int main(){
	double R;
	while(cin>>x>>y){
		int f[5],ans=0;
		memset(f,0,sizeof(f));
		struct node d[5]; 
		for(int i=0;i<5;++i){
			scanf("%d%d%d",&d[i].x,&d[i].y,&d[i].hp);
			d[i].k=ak(d[i].x,d[i].y);
			d[i].l=al(d[i].x,d[i].y);
		}
		cin>>L>>R;
		for(int i=0;i<5;++i){
			for(int m=i+1;m<5;++m){
				if(d[i].k==d[m].k){
					if(d[i].l>d[m].l)
					f[i]=1;
					else
					f[m]=1;
				}	
			}
			if(d[i].l>L)
			f[i]=1;
		}
		for(int i=0;i<5;++i){
			if(!f[i]){
				if(d[i].hp<=R*d[i].l)
				ans=1;
			}
		}
		if(ans)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
		
	}
}

Double click to view unformatted code.


Back to problem 32