View Code of Problem 12

#include<stdio.h>
#include<math.h>
int main(){
int n,flag,k=3,i;
double v,d,st,f0,f1,t;
scanf("%d",&n);
for(i=1;i<=n;i++){
scanf("%d%lf%lf%lf",&flag,&f0,&f1,&t);
if(flag==1) printf("Target%d:NO:ONE OF US\n",i);
else if(f0>f1)  printf("Target%d:NO:AWAY\n",i);
else{
v=(f1-f0)/(f1+f0)*299792458;
d=299792458*t*pow(10,-6)/2;
if(d<200000){
	if(k>0) {
		printf("Target%d:YES\n",i);
	    k--;
	}
	else{
	printf("Target%d:NO:NEXT TIME\n",i);
	}
}
else{
st=(d-200000)/v;
printf("Target%d:NO:%.4f\n",i,st);
}
}
}
}

Double click to view unformatted code.


Back to problem 12