View Code of Problem 32

#include<iostream>
#include<cmath>
using namespace std;
int main() {
	int x0,y0,
	while(cin>>x0>>y0) {
		int x[5],y[5],hp[5],L;
		double R;
		for(int i=0; i<5; i++) cin>>x[i]>>y[i]>>hp[i];
		cin>>L>>R;
		int flag=0;//是否能干掉一个英雄 
		for(int i=0; i<5; i++) {
			//首先计算两个英雄相距d
			double d=sqrt(pow(x0-x[i],2)+pow(y0-y[i],2));
			//判断d是否超过L
			if(d>L) break;
			//如果没有超过 计算hp-d*R是否<=0 
			if(hp[i]<=d*R) {
				flag=1;//可以击杀
				break; 
			}
		}
		if(flag==1) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
}
/*
Main.cc: In function 'int main()':
Main.cc:6:2: error: expected unqualified-id before 'while'
  while(cin>>x0>>y0) {
  ^~~~~
Main.cc:5:6: warning: unused variable 'x0' [-Wunused-variable]
  int x0,y0,
      ^~
Main.cc:5:9: warning: unused variable 'y0' [-Wunused-variable]
  int x0,y0,
         ^~
*/

Double click to view unformatted code.


Back to problem 32