/home/toolbox/public_html/solutions/111/11137/a.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[23] = {0, 1, 8, 27, 64, 125, 216, 343, 512, 729, 1000, 1331, 1728,
34 2197, 2744, 3375, 4096, 4913, 5832, 6859, 8000, 9261, 10648
35 };
36 long long 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 j;
56
57 amounts[0] = 1;
58 for (i=1; coins[i] < MAX_VALUES; i++)
59 {
60 /* for i */
61 for (j=coins[i]; j < MAX_VALUES; j++)
62 {
63 /* for j */
64 amounts[j] = amounts[j] + amounts[j-coins[i]];
65 } /* for j */
66 } /* for i */
67 } /* FUNCTION init */
68
69 void dump()
70 {
71 /* FUNCTION dump */
72 } /* FUNCTION dump */
73
74 int getInput()
75 {
76 /* FUNCTION getInput */
77 int dataReadFlag;
78
79 dataReadFlag = (1 == scanf(" %d ", &num));
80 return (dataReadFlag);
81 } /* FUNCTION getInput */
82
83 void process()
84 {
85 /* FUNCTION process */
86 printf("%llu\n", amounts[num]);
87 } /* FUNCTION process */
88
89 int main()
90 {
91 /* main */
92 int moreToDo;
93
94 init();
95 moreToDo = getInput();
96 while (moreToDo)
97 {
98 /* while */
99 process();
100 moreToDo = getInput();
101 } /* while */
102
103 return EXIT_SUCCESS;
104 } /* main */
105