Computer Programming Contest Preparation

ToolBox - Source for: 13/1388/a.c



/home/toolbox/public_html/solutions/13/1388/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 <stdint.h>
    7 #include <math.h>
    8 #include <stdlib.h>
    9 #include <ctype.h>
   10 
   11 #define TRUE  (1 == 1)
   12 #define FALSE (1 != 1)
   13 
   14 #define DEBUG if (FALSE)
   15 
   16 #define MAX_LINE 257
   17 
   18 /*
   19  *  Author: Isaac Traxler
   20  *    Date: 2021-12-17
   21  * Purpose: fun
   22  * Problem: 1388 - Graveyard
   23  */
   24 
   25 /*
   26  * This template reads lines of data at a time until end of file.
   27  */
   28 
   29 int cur;
   30 int add;
   31 double curD;
   32 double addD;
   33 double dist;
   34 double toMove;
   35 
   36 void init()
   37 {
   38     /* FUNCTION init */
   39 } /* FUNCTION init */
   40 
   41 void dump()
   42 {
   43     /* FUNCTION dump */
   44 } /* FUNCTION dump */
   45 
   46 int getInput()
   47 {
   48     /* FUNCTION getInput */
   49     int dataReadFlag;
   50 
   51     dataReadFlag = (2 == scanf(" %d %d ", &cur, &add));
   52     return (dataReadFlag);
   53 } /* FUNCTION getInput */
   54 
   55 void process()
   56 {
   57     /* FUNCTION process */
   58     if (0 == (add % cur))
   59         {
   60             /* none to move */
   61             printf("0.0\n");
   62         } /* none to move */
   63     else
   64         {
   65             /* must move some */
   66             curD = (double) cur;
   67             addD = (double) add;
   68             toMove = (double) (add % cur);
   69             dist = (toMove / (curD + addD) * 5000);
   70             printf("%.4lf\n", dist);
   71         } /* must move some */
   72 } /* FUNCTION process */
   73 
   74 int main()
   75 {
   76     /* main */
   77     int moreToDo;
   78 
   79     init();
   80     moreToDo = getInput();
   81     while (moreToDo)
   82         {
   83             /* while */
   84             process();
   85             moreToDo = getInput();
   86         } /* while */
   87 
   88     return EXIT_SUCCESS;
   89 } /* main */
   90