View Code of Problem 12

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main()
{
    int t, count = 0, lj = 0;
    
    
    {
        scanf("%d", &t);
        
        while (t--) {
            count++;
            double f1, f0;
            int p, time;
            
            scanf("%d%lf%lf%d", &p, &f0, &f1, &time);
            printf("Target%d:", count);
            if (p == 1) {
                printf("NO:ONE OF US\n");
            }
            else {
                double x = f1 / f0;
                double v = (x - 1) * 299792458 / (x + 1);
                
                if (v < 0.0) {
                    printf("NO:AWAY\n");
                }
                else {
                    double s = 299792458/ 1000000.0 * time  / 2;
                    if(s < 200000.0)
                    {
                        if (lj < 3) {
                            printf("YES\n");
                        }
                        else{
                            printf("NO:NEXT TIME\n");
                        }
                        lj++;
                    }
                    else {
                        printf("NO:%.4lf\n", (s - 200000) / v);
                    }
                }
            }
        }
    }
}

Double click to view unformatted code.


Back to problem 12