Computer Programming Contest Preparation

ToolBox - Source for: 117/11723/a.c



/home/toolbox/public_html/solutions/117/11723/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: 2025-02-24
   19  * Purpose: fun
   20  * Problem: 11723
   21  */
   22 
   23 /*
   24  * This template reads data until a terminating value is reached.
   25  */
   26 
   27 /* count blank as a suffix */
   28 #define MAX_SUFFIXES 27
   29 
   30 int r;
   31 int n;
   32 int cnt;
   33 
   34 void init()
   35 {
   36     /* FUNCTION init */
   37     cnt = 0;
   38 } /* FUNCTION init */
   39 
   40 void dump()
   41 {
   42     /* FUNCTION dump */
   43 } /* FUNCTION dump */
   44 
   45 int getInput()
   46 {
   47     /* FUNCTION getInput */
   48     int dataReadFlag;
   49     scanf(" %d %d ", &r, &n);
   50     dataReadFlag = (0 != r) && (0 != n);
   51     return (dataReadFlag);
   52 } /* FUNCTION getInput */
   53 
   54 void process()
   55 {
   56     /* FUNCTION process */
   57     int d;
   58 
   59     d = ((r + n - 1) / n) - 1;
   60     if (MAX_SUFFIXES > d)
   61         {
   62             /* print number of suffixes */
   63             printf("%d", d);
   64         } /* print number of suffixes */
   65     else
   66         {
   67             /* impossible */
   68             printf("impossible");
   69         } /* impossible */
   70     printf("\n");
   71 
   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             cnt++;
   85             printf("Case %d: ", cnt);
   86             process();
   87             moreToDo = getInput();
   88         } /* while */
   89 
   90     return EXIT_SUCCESS;
   91 } /* main */
   92