Computer Programming Contest Preparation

ToolBox - Source for: 101/10170/a.c



/home/toolbox/public_html/solutions/101/10170/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 /*
   17  *  Author: Isaac Traxler
   18  *    Date: 2023-10-17
   19  * Purpose: fun
   20  * Problem: 10170 - The Hotel with Infinite Rooms
   21  */
   22 
   23 /*
   24  * This template reads data until a terminating value is reached.
   25  *
   26  */
   27 
   28 
   29 int start;
   30 long day;
   31 
   32 void init()
   33 {
   34     /* FUNCTION init */
   35 } /* FUNCTION init */
   36 
   37 void dump()
   38 {
   39     /* FUNCTION dump */
   40 } /* FUNCTION dump */
   41 
   42 int getInput()
   43 {
   44     /* FUNCTION getInput */
   45     int dataReadFlag;
   46 
   47     dataReadFlag = ! feof(stdin);
   48     if (dataReadFlag)
   49         {
   50             /* something to read */
   51             scanf(" %d %ld ", &start, &day);
   52         } /* something to read */
   53     return (dataReadFlag);
   54 } /* FUNCTION getInput */
   55 
   56 void process()
   57 {
   58     /* FUNCTION process */
   59     int i;
   60     int groupSize;
   61     long cur;
   62 
   63     cur = 0;
   64     groupSize = start - 1;
   65     for (i=1; cur<day; i++)
   66         {
   67             /* each day */
   68             groupSize++;
   69             cur = cur + groupSize;
   70         } /* each day */
   71     printf("%d\n", groupSize);
   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