View Code of Problem 12

#include <iostream>
using namespace std;
int main(){
	int t,i=1,count=0;
	cin>>t;
	while(t--){
		int flag;
		double k=200000;
		double f0,f1;
		int t;
		cin>>flag>>f0>>f1>>t;
		double c=299792458;
		double distance=c/1000000*t/2;
		double temp=f1/f0;
		double v=(temp-1)*c/(temp+1);
		cout<<"Target"<<i++<<":";
		if(flag==1){
			cout<<"NO:ONE OF US"<<endl;
		}
		else{
			if(f1<f0){
				cout<<"NO:AWAY"<<endl;
			}
			else if(distance<k){
				if(count<3){ 
					cout<<"YES"<<endl;
					count++; 
				}
				else	cout<<"NO:NEXT TIME"<<endl;
			}
			else{
				printf("NO:%.4lf\n",(distance-k)/v);
			}
		}
	}
} 

Double click to view unformatted code.


Back to problem 12