Computer Programming Contest Preparation

ToolBox - Source for: 128/12808/a.c



/home/toolbox/public_html/solutions/128/12808/a.c
    1 #include <stdio.h>
    2 #include <string.h>
    3 #include <sys/types.h>
    4 #include <sys/stat.h>
    5 #include <fcntl.h>
    6 #include <stdlib.h>
    7 #include <math.h>
    8 #include <stdint.h>
    9 
   10 #define TRUE  (1 == 1)
   11 #define FALSE (1 != 1)
   12 
   13 #define DEBUG if (FALSE)
   14 
   15 /* fprintf(stderr, "functionName: message", varslist); */
   16 
   17 /*
   18  *  Author: Isaac Traxler
   19  *    Date: 2015-10-18
   20  * Purpose: fun
   21  * Problem: 12808 - Banning Balcony
   22  */
   23 
   24 /*
   25  * This template reads data a specified number of times.
   26  */
   27 
   28 #define GRAVITY (9.81 * 1000)
   29 #define CLOSE 500
   30 
   31 int numberOfTimes;
   32 double L;
   33 double D;
   34 double H;
   35 double V;
   36 
   37 void init()
   38 {
   39     /* FUNCTION init */
   40     scanf("%d ", &numberOfTimes);
   41 } /* FUNCTION init */
   42 
   43 void dump()
   44 {
   45     /* FUNCTION dump */
   46 } /* FUNCTION dump */
   47 
   48 void getInput()
   49 {
   50     /* FUNCTION getInput */
   51     scanf(" %lf %lf %lf %lf ", &L, &D, &H, &V);
   52     DEBUG printf(" L=%lf  D=%lf  H=%lf  V=%lf\n", L, D, H, V);
   53 } /* FUNCTION getInput */
   54 
   55 void process()
   56 {
   57     /* FUNCTION process */
   58     double distance;
   59 
   60     distance = sqrt(2 * V * V * H / GRAVITY);
   61     if (((D-CLOSE) > distance) || ((D + L + CLOSE) < distance))
   62         {
   63             /* missed the pool */
   64             printf("FLOOR\n");
   65         } /* missed the pool */
   66     else if (((D+CLOSE) < distance) && ((D+L-CLOSE)>distance))
   67         {
   68             /* in pool */
   69             printf("POOL\n");
   70         } /* in pool */
   71     else
   72         {
   73             /* edge */
   74             printf("EDGE\n");
   75         } /* edge */
   76 } /* FUNCTION process */
   77 
   78 int main()
   79 {
   80     /* main */
   81     int i;
   82 
   83     init();
   84     for (i=0; i<numberOfTimes; i++)
   85         {
   86             /* while */
   87             getInput();
   88             process();
   89         } /* while */
   90 
   91     return EXIT_SUCCESS;
   92 } /* main */
   93 
   94