View Code of Problem 12

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#define c 299792458

int main() {
	int t;
	scanf("%d", &t);
	int flag,time;
	double f0, f1;
	int count = 0;
	for (int i = 1;i <= t;i++) {
		scanf("%d %lf %lf %d", &flag, &f0, &f1, &time);
		if (flag) {
			printf("Target%d:NO:ONE OF US\n", i);
		}
		else {
			double v = c * (f1 - f0) / (f0 + f1);
			if (v < 0) {
				printf("Target%d:NO:AWAY\n", i);
			}
			else {
				double dis = (double)c * time * 0.000001 / 2;
				if (dis > 200000) {
					double T = (dis - 200000) / v;
					printf("Target%d:NO:%.4lf\n", i, T);
				}
				else {
					if (count < 3) {
						count++;
						printf("Target%d:YES\n", i);
					}
					else {
						printf("Target%d:NO:NEXT TIME\n", i);
					}
				}
			}
		}
	}
}

Double click to view unformatted code.


Back to problem 12