View Code of Problem 12

#include<bits/stdc++.h>
using namespace std;

#define c 299792458

int main() {

	int n;
	cin>>n;
	int num=3;
	for(int i=1; i<=n; i++) {
		int what;
		cin>>what;
		double f1,f0;
		cin>>f0>>f1;
		double time;
		cin>>time;
		if(what==1) {
			cout<<"Target"<<i<<":NO:ONE OF US"<<endl;
		} else {
			double v=(f1-f0)/(f0+f1)*c;
			if(v<=0) {
				cout<<"Target"<<i<<":NO:AWAY"<<endl;
			} else {
				double lu=time/2*c/1e6;
				if(lu<200000) {
					if(num>0) {
						num--;
						cout<<"Target"<<i<<":YES"<<endl;
					} else {
						cout<<"Target"<<i<<":NO:NEXT TIME"<<endl;
					}
				} else {
					double lan=(lu-200000)/v;
					printf("Target%d:NO:%.4lf\n",i,lan);
				}
			}
		}
	}

	return 0;
}

Double click to view unformatted code.


Back to problem 12