Computer Programming Contest Preparation

ToolBox - Source for: naq/2026/f.c



/home/toolbox/public_html/solutions/naq/2026/f.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: 2026-10-03
   21  * Purpose: fun
   22  * Problem: f - fairies
   23  */
   24 
   25 /*
   26  * This template reads data a specified number of times.
   27  */
   28 
   29 int numberOfTimes;
   30 int noteCnt;
   31 int strngs[4];
   32 
   33 void init()
   34 {
   35     /* FUNCTION init */
   36     scanf("%d ", &numberOfTimes);
   37 } /* FUNCTION init */
   38 
   39 void dump()
   40 {
   41     /* FUNCTION dump */
   42 } /* FUNCTION dump */
   43 
   44 void getInput()
   45 {
   46     /* FUNCTION getInput */
   47     int i;
   48     int tmp;
   49 
   50     strngs[0] = 0;
   51     strngs[1] = 0;
   52     strngs[2] = 0;
   53     strngs[3] = 0;
   54     scanf(" %d ", &noteCnt);
   55     for (i=0; i<noteCnt; i++)
   56         {
   57             /* for each note */
   58             scanf(" %d ", &tmp);
   59             DEBUG printf("(note %d)", tmp);
   60             tmp = (tmp - 1) / 10;
   61             DEBUG printf("(string %d)\n", tmp);
   62             strngs[tmp] = 1;
   63         } /* for each note */
   64 } /* FUNCTION getInput */
   65 
   66 void process()
   67 {
   68     /* FUNCTION process */
   69     int tot;
   70     int i;
   71 
   72     tot = 0;
   73     DEBUG printf("%d %d %d %d = %d\n", strngs[0], strngs[1], strngs[2], strngs[3], tot);
   74     for (i=0; i<4; i++)
   75         {
   76             tot = tot + strngs[i];
   77         }
   78     DEBUG printf("%d %d %d %d = %d\n", strngs[0], strngs[1], strngs[2], strngs[3], tot);
   79     printf("%d\n", tot);
   80 } /* FUNCTION process */
   81 
   82 int main()
   83 {
   84     /* main */
   85     int i;
   86 
   87     init();
   88     for (i=0; i<numberOfTimes; i++)
   89         {
   90             /* while */
   91             getInput();
   92             process();
   93         } /* while */
   94 
   95     return EXIT_SUCCESS;
   96 } /* main */
   97 
   98