Computer Programming Contest Preparation

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



/home/toolbox/public_html/solutions/naq/2026/kc.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: k Six Seven
   23  */
   24 
   25 /*
   26  * This template reads data a specified number of times.
   27  */
   28 
   29 #define MAXX 37
   30 
   31 int numberOfTimes;
   32 int num;
   33 int chk[MAXX] =
   34 {
   35     12,       23,      34,     45,    56,   67,  78, 89,
   36     123,      234,     345,    456,   567,  678, 789,
   37     1234,     2345,    3456,   4567,  5678, 6789,
   38     12345,    23456,   34567,  45678, 56789,
   39     123456,   234567,  345678, 456789,
   40     1234567,  2345678, 3456789,
   41     12345678, 23456789,
   42     123456789,
   43     123456789
   44 };
   45 
   46 void init()
   47 {
   48     /* FUNCTION init */
   49     scanf("%d ", &numberOfTimes);
   50 } /* FUNCTION init */
   51 
   52 void dump()
   53 {
   54     /* FUNCTION dump */
   55 } /* FUNCTION dump */
   56 
   57 void getInput()
   58 {
   59     /* FUNCTION getInput */
   60     scanf("%d ", &num);
   61 } /* FUNCTION getInput */
   62 
   63 void process()
   64 {
   65     /* FUNCTION process */
   66     int i;
   67 
   68     /* if (num < 9) { printf("%d\n", num); }*/
   69     if (num < 10)
   70         {
   71             printf("%d\n", num);
   72         }
   73     /* else if (123456789 < num) { printf("-1\n"); } */
   74     else if (100000000 < num)
   75         {
   76             printf("-1\n");
   77         }
   78     else
   79         {
   80             /* not first 8 numbers */
   81             for (i=0; chk[i] < num; i++)
   82                 {
   83                     DEBUG printf("(num %d) (chk[%d] %d)\n", num, i, chk[i]);
   84                 }
   85             printf("%d\n", chk[i]);
   86         } /* not first 8 numbers */
   87 
   88 } /* FUNCTION process */
   89 
   90 int main()
   91 {
   92     /* main */
   93     int i;
   94 
   95     init();
   96     for (i=0; i<numberOfTimes; i++)
   97         {
   98             /* while */
   99             getInput();
  100             process();
  101         } /* while */
  102 
  103     return EXIT_SUCCESS;
  104 } /* main */
  105 
  106