Computer Programming Contest Preparation

ToolBox - Source for: 116/11689/a.c



/home/toolbox/public_html/solutions/116/11689/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 #include <ctype.h>
   10 
   11 #define TRUE  (1 == 1)
   12 #define FALSE (1 != 1)
   13 
   14 #define DEBUG if (FALSE)
   15 
   16 /* fprintf(stderr, "functionName: message", varslist); */
   17 
   18 /*
   19  *  Author: Isaac Traxler
   20  *    Date: 2021-12-6
   21  * Purpose: fun
   22  * Problem: 11689 - Soda Surpler
   23  */
   24 
   25 /*
   26  * This template reads data a specified number of times.
   27  */
   28 
   29 int numberOfTimes;
   30 int e; /* number of empties to start day with */
   31 int f; /* number of empties found during day */
   32 int c; /* cost of a soda */
   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(" %d %d %d ", &e, &f, &c);
   49 } /* FUNCTION getInput */
   50 
   51 void process()
   52 {
   53     /* FUNCTION process */
   54     int tot;
   55     int drank = 0;
   56     int tmp;
   57 
   58     tot = e + f;
   59     while (c <= tot)
   60         {
   61             /* drink and return */
   62             tmp = tot / c;
   63             drank = drank + tmp;
   64             tot = (tot % c) + tmp;
   65         } /* drink and return */
   66     printf("%d\n", drank);
   67 } /* FUNCTION process */
   68 
   69 int main()
   70 {
   71     /* main */
   72     int i;
   73 
   74     init();
   75     for (i=0; i<numberOfTimes; i++)
   76         {
   77             /* while */
   78             getInput();
   79             process();
   80         } /* while */
   81 
   82     return EXIT_SUCCESS;
   83 } /* main */
   84 
   85