Computer Programming Contest Preparation

ToolBox - Source for: 127/12725/a.c



/home/toolbox/public_html/solutions/127/12725/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-09-30
   20  * Purpose: fun
   21  * Problem: 12725
   22  */
   23 
   24 /*
   25  * This template reads data a specified number of times.
   26  */
   27 
   28 int numberOfTimes;
   29 double N;
   30 double M;
   31 int A;
   32 int B;
   33 
   34 void init()
   35 {
   36     /* FUNCTION init */
   37     scanf("%d ", &numberOfTimes);
   38 } /* FUNCTION init */
   39 
   40 void dump()
   41 {
   42     /* FUNCTION dump */
   43 } /* FUNCTION dump */
   44 
   45 void getInput()
   46 {
   47     /* FUNCTION getInput */
   48     scanf(" %lf %lf %d %d", &M, &N, &A, &B);
   49 } /* FUNCTION getInput */
   50 
   51 void process()
   52 {
   53     /* FUNCTION process */
   54     double goal;
   55 
   56     goal = ((N * (A + B)) - (M * A)) / B;
   57     DEBUG printf("M=%lf  N=%lf  A=%d  B=%d\n", M, N, A, B);
   58     DEBUG printf(" goal = %lf\n", goal);
   59     if ((10 < goal) || (0 > goal))
   60         {
   61             printf("Impossible\n");
   62         }
   63     else
   64         {
   65             printf("%.2lf\n", goal);
   66         }
   67 } /* FUNCTION process */
   68 
   69 int main()
   70 {
   71     /* main */
   72     int i;
   73 
   74     init();
   75     for (i=1; i<=numberOfTimes; i++)
   76         {
   77             /* while */
   78             printf("Case #%d: ", i);
   79             getInput();
   80             process();
   81         } /* while */
   82 
   83     return EXIT_SUCCESS;
   84 } /* main */
   85 
   86