Computer Programming Contest Preparation

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



/home/toolbox/public_html/solutions/116/11636/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 
   10 #define TRUE  (1 == 1)
   11 #define FALSE (1 != 1)
   12 
   13 #define DEBUG if (FALSE)
   14 
   15 /*
   16  *  Author: Isaac Traxler
   17  *    Date: 2015-10-05
   18  * Purpose: fun
   19  * Problem: 11636
   20  */
   21 
   22 /*
   23  * This template reads data until a terminating value is reached.
   24  */
   25 
   26 int twos[32];
   27 int num;
   28 
   29 void init()
   30 {
   31     /* FUNCTION init */
   32     int tmp = 1;
   33     int i;
   34 
   35     twos[0] = 1;
   36     for (i=1; 31>i; i++)
   37         {
   38             /* load twos */
   39             tmp = tmp * 2;
   40             twos[i] = tmp;
   41         } /* load twos */
   42 } /* FUNCTION init */
   43 
   44 void dump()
   45 {
   46     /* FUNCTION dump */
   47 } /* FUNCTION dump */
   48 
   49 int getInput()
   50 {
   51     /* FUNCTION getInput */
   52     int dataReadFlag;
   53 
   54     scanf(" %d ", &num);
   55     dataReadFlag = (0 < num);
   56     return (dataReadFlag);
   57 } /* FUNCTION getInput */
   58 
   59 void process()
   60 {
   61     /* FUNCTION process */
   62     int i = 0;
   63 
   64     while (twos[i] < num)
   65         {
   66             i++;
   67         }
   68     printf("%d\n", i);
   69 
   70 } /* FUNCTION process */
   71 
   72 int main()
   73 {
   74     /* main */
   75     int moreToDo;
   76     int cse = 1;
   77 
   78     init();
   79     moreToDo = getInput();
   80     while (moreToDo)
   81         {
   82             /* while */
   83             printf("Case %d: ", cse);
   84             cse++;
   85             process();
   86             moreToDo = getInput();
   87         } /* while */
   88 
   89     return EXIT_SUCCESS;
   90 } /* main */
   91