View Code of Problem 12

#include<iostream>
#include<vector>
#include<iomanip>
using namespace std;
int main() {
	double c = 299792458;
	int T; cin >> T; int k = 3,p=0;
	while (T--) {
		int a, t;
		double f1,f0;
		cin >> a >> f0 >> f1 >> t;
		cout << "Target" << ++p << ":"; 
		double v = (f1 - f0)*c / (f1 + f0),
			dist =  c / 1000000 / 2 * t ;
		if (a)cout << "NO:ONE OF US\n";
		else if (f0 > f1)cout << "NO:AWAY\n";
		else if (dist < 200000) {
			if(k){ cout << "YES\n"; k--; }
			else cout << "NO:NEXT TIME\n";
		}
		else cout << "NO:" << fixed << setprecision(4) << (dist - 200000) / v << endl;
	}
}

Double click to view unformatted code.


Back to problem 12