/home/toolbox/public_html/solutions/111/11137/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 <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_ARRAY 10649
30 #define MAX_VALUES 10002
31
32 int num;
33 int coins[22] = {1, 8, 27, 64, 125, 216, 343, 512, 729, 1000, 1331, 1728,
34 2187, 2744, 3375, 4096, 4913, 5832, 6859, 8000, 9261, 10648
35 };
36 int amounts[MAX_ARRAY];
37
38 int rank(int x)
39 {
40 /* FUNCTION rank */
41 int i;
42
43 while (x > coins[i])
44 {
45 /* while */
46 i++;
47 } /* while */
48 return (i);
49 } /* FUNCTION rank */
50
51 void init()
52 {
53 /* FUNCTION init */
54 int i;
55 int cur;
56 int c;
57 int j;
58
59 cur = 2;
60 c = 1;
61 i = 8;
62 amounts[0] = 0;
63 amounts[1] = 1;
64 amounts[2] = 1;
65 amounts[3] = 1;
66 amounts[4] = 1;
67 amounts[5] = 1;
68 amounts[6] = 1;
69 amounts[7] = 1;
70 amounts[8] = 2;
71 while (MAX_VALUES > i)
72 {
73 /* while */
74 while (i < coins[c + 1])
75 {
76 /* while */
77 for (j=0; (MAX_VALUES>i) && (coins[c+1]>i) && (coins[c]>j); j++)
78 {
79 /* for */
80 amounts[i] = cur;
81 printf("amounts[%d] = %d\n", i, cur);
82 i++;
83 } /* for */
84 cur++;
85 } /* while */
86 c++;
87 } /* while */
88 } /* FUNCTION init */
89
90 void dump()
91 {
92 /* FUNCTION dump */
93 } /* FUNCTION dump */
94
95 int getInput()
96 {
97 /* FUNCTION getInput */
98 int dataReadFlag;
99
100 dataReadFlag = (1 == scanf(" %d ", &num));
101 return (dataReadFlag);
102 } /* FUNCTION getInput */
103
104 void process()
105 {
106 /* FUNCTION process */
107 } /* FUNCTION process */
108
109 int main()
110 {
111 /* main */
112 int moreToDo;
113
114 init();
115 moreToDo = getInput();
116 while (moreToDo)
117 {
118 /* while */
119 process();
120 moreToDo = getInput();
121 } /* while */
122
123 return EXIT_SUCCESS;
124 } /* main */
125