Computer Programming Contest Preparation

ToolBox - Source for: 126/12626/c.c



/home/toolbox/public_html/solutions/126/12626/c.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-10-06
   20  * Purpose: fun
   21  * Problem: 12626 - I Love Pizza
   22  */
   23 
   24 /*
   25  * This template reads data a specified number of times.
   26  */
   27 
   28 #define MAX_SIZE 625
   29 #define M 'M'
   30 #define A 'A'
   31 #define R 'R'
   32 #define G 'G'
   33 #define I 'I'
   34 #define T 'T'
   35 
   36 int numberOfTimes;
   37 char buff[MAX_SIZE];
   38 int letters[256];
   39 
   40 void init()
   41 {
   42     /* FUNCTION init */
   43     scanf("%d ", &numberOfTimes);
   44 } /* FUNCTION init */
   45 
   46 void dump()
   47 {
   48     /* FUNCTION dump */
   49 } /* FUNCTION dump */
   50 
   51 void getInput()
   52 {
   53     /* FUNCTION getInput */
   54     int i;
   55 
   56     for (i=0; i<256; i++)
   57         {
   58             letters[i] = 0;
   59         }
   60     scanf(" %s ", buff);
   61 } /* FUNCTION getInput */
   62 
   63 void process()
   64 {
   65     /* FUNCTION process */
   66     int i;
   67     int min;
   68     int tmp;
   69 
   70     for (i=0; i<strlen(buff); i++)
   71         {
   72             letters[buff[i]]++;
   73         }
   74     letters[A] = letters[A] / 3;
   75     letters[R] = letters[R] >> 1;
   76     for (i=0; (i<letters[A]) && (i<letters[M]) && (i<letters[R]) && (i<letters[I]) && (i<letters[G]) && (i<letters[T]); i++);
   77     printf("%d\n", i);
   78 } /* FUNCTION process */
   79 
   80 int main()
   81 {
   82     /* main */
   83     int i;
   84 
   85     init();
   86     for (i=0; i<numberOfTimes; i++)
   87         {
   88             /* while */
   89             getInput();
   90             process();
   91         } /* while */
   92 
   93     return EXIT_SUCCESS;
   94 } /* main */
   95 
   96