View Code of Problem 12

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

Double click to view unformatted code.


Back to problem 12