/home/toolbox/public_html/solutions/104/10419/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
9 #define TRUE (1 == 1)
10 #define FALSE (1 != 1)
11
12 #define DEBUG if (FALSE)
13
14 #define MAX_PRIME 300
15 #define MAX_T 14
16
17 /*
18 * Author:
19 * Date:
20 * Purpose:
21 * Problem:
22 */
23
24 int n, t;
25 int minN[MAX_T + 1];
26 int maxN[MAX_T + 1];
27 int primes[MAX_PRIME + 1];
28 int primeCount;
29 int caseNumber;
30
31 int init()
32 {
33 /* FUNCTION init */
34 int i, j;
35 int min, max;
36
37 // find the primes
38 primeCount = 0;
39
40 for (i = 0; i < MAX_PRIME; i++)
41 {
42 primes[i] = i;
43 }
44
45 for (i = 2; i < MAX_PRIME; i++)
46 {
47 if (0 != primes[i])
48 {
49 primes[primeCount] = i;
50 primeCount++;
51
52 for (j = 2 * i; j < MAX_PRIME; j += i)
53 {
54 primes[j] = 0;
55 }
56 }
57 }
58
59 // find the min/max for each value of t
60 min = 2;
61 max = 0;
62
63 minN[0] = 2;
64 for (i = 1; i < MAX_T; i+=2)
65 {
66 min += primes[i];
67 minN[i] = min;
68 min += primes[i];
69 minN[i+1] = min;
70 }
71
72 for (i = 0; i < MAX_T; i++)
73 {
74 printf("minN[%d] = %d\n", i, minN[i]);
75 }
76
77 // now do everything else
78 caseNumber = 1;
79
80 } /* FUNCTION init */
81
82 int dump()
83 {
84 /* FUNCTION dump */
85 } /* FUNCTION dump */
86
87 int getInput()
88 {
89 /* FUNCTION getInput */
90 int dataReadFlag;
91
92 scanf("%d %d", &n, &t);
93
94 if (0 == n)
95 dataReadFlag = FALSE;
96 else
97 dataReadFlag = TRUE;
98
99 return (dataReadFlag);
100 } /* FUNCTION getInput */
101
102 void process()
103 {
104 /* FUNCTION process */
105 int i, min, max;
106 DEBUG printf("n=%d t=%d\n", n, t);
107
108 printf("CASE %d:\n", caseNumber);
109
110 // see if n is between the smallest and largest possible
111
112
113
114
115
116
117 caseNumber++;
118 } /* FUNCTION process */
119
120 int main ()
121 {
122 /* main */
123 int moreToDo;
124
125 init();
126 moreToDo = getInput();
127 while (moreToDo)
128 {
129 /* while */
130 process();
131 moreToDo = getInput();
132 } /* while */
133
134 return 1;
135 } /* main */
136