Computer Programming Contest Preparation

ToolBox - Source for: 111/11137/b.c



/home/toolbox/public_html/solutions/111/11137/b.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 #define MAX_LINE 257
   17 
   18 /*
   19  *  Author: Isaac Traxler
   20  *    Date: 2022-08-24
   21  * Purpose: fun
   22  * Problem: 11137 - Ingenuous Cubrency
   23  */
   24 
   25 /*
   26  * This template reads lines of data at a time until end of file.
   27  */
   28 
   29 #define MAX_VALUES 10002
   30 
   31 int num;
   32 int coins[21] = {1, 8, 27, 64, 125, 216, 343, 512, 729, 1000, 1331, 1728, 2187, 2744, 3375, 4096, 4913, 5832, 6859, 8000, 9261}
   33                 int amounts[MAX_VALUES];
   34 
   35 int rank(int x)
   36 {
   37     /* FUNCTION rank */
   38     int i;
   39 
   40     while (x > coins[i])
   41         {
   42             /* while */
   43             i++;
   44         } /* while */
   45     return (i);
   46 } /* FUNCTION rank */
   47 
   48 void init()
   49 {
   50     /* FUNCTION init */
   51     amounts[0] = 0;
   52     amounts[1] = 1;
   53     amounts[2] = 1;
   54     amounts[3] = 1;
   55     amounts[4] = 1;
   56     amounts[5] = 1;
   57     amounts[6] = 1;
   58     amounts[7] = 1;
   59     amounts[8] = 2;
   60     amounts[9] = 2;
   61     for (i=10; MAX_VALUES>i; i++)
   62         {
   63             /* for */
   64             calc(i);
   65         } /* for */
   66 } /* FUNCTION init */
   67 
   68 void dump()
   69 {
   70     /* FUNCTION dump */
   71 } /* FUNCTION dump */
   72 
   73 int getInput()
   74 {
   75     /* FUNCTION getInput */
   76     int dataReadFlag;
   77 
   78     dataReadFlag = (1 == scanf(" %d ", &num));
   79     return (dataReadFlag);
   80 } /* FUNCTION getInput */
   81 
   82 void process()
   83 {
   84     /* FUNCTION process */
   85 } /* FUNCTION process */
   86 
   87 int main()
   88 {
   89     /* main */
   90     int moreToDo;
   91 
   92     init();
   93     moreToDo = getInput();
   94     while (moreToDo)
   95         {
   96             /* while */
   97             process();
   98             moreToDo = getInput();
   99         } /* while */
  100 
  101     return EXIT_SUCCESS;
  102 } /* main */
  103