/home/toolbox/public_html/solutions/125/12527/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:
21 * Purpose: fun
22 * Problem:
23 */
24
25 /*
26 * This template reads lines of data at a time until end of file.
27 */
28
29 int n;
30 int m;
31 int list[5001];
32 int digits[10];
33
34 int dupes(int x)
35 {
36 /* FUNCTON dupes */
37 /* this returns 1 if duplicate digits found, otherwise it returns 0 */
38 int i;
39 int toReturn = 1;
40 int tmp;
41
42 tmp = x;
43 for (i=0; 10>i; i++)
44 {
45 digits[i] = 0;
46 }
47 if (999 < x)
48 {
49 /* thousands digit present */
50 digits[x / 1000] = 1;
51 x = x % 1000;
52 } /* thousands digit present */
53 if (99 < x)
54 {
55 /* hundreds digit present */
56 digits[x / 100] += 1;
57 x = x % 100;
58 } /* hundreds digit present */
59 if (9 < x)
60 {
61 /* tens digit present */
62 digits[x / 10] += 1;
63 x = x % 10;
64 } /* tens digit present */
65 digits[x] += 1;
66 for (i=0; 10>i; i++)
67 {
68 if (1 < digits[i])
69 {
70 toReturn = 0;
71 }
72 }
73 if (0 == toReturn)
74 {
75 printf("dupes: %d\n", tmp);
76 }
77 return toReturn;
78 } /* FUNCTON dupes */
79
80 void init()
81 {
82 /* FUNCTION init */
83 int i;
84
85 for(i=0; 10>i; i++)
86 {
87 list[i] = 0;
88 }
89 for (i=11; 5001>i; i++)
90 {
91 /* check the number */
92 list[i] = dupes(i);
93 } /* check the number */
94 for (i=100; 5001>i; i=i+100)
95 {
96 /* do numbers that end in 2 zeroes */
97 list[i] = 1;
98 } /* do numbers that end in 2 zeroes */
99 for (i=1001; 1010>i; i=i++)
100 {
101 /* do numbers that end in 2 zeroes */
102 list[i] = 1;
103 } /* do numbers that end in 2 zeroes */
104 list[100] = 1;
105 list[100] = 1;
106 } /* FUNCTION init */
107
108 void dump()
109 {
110 /* FUNCTION dump */
111 } /* FUNCTION dump */
112
113 int getInput()
114 {
115 /* FUNCTION getInput */
116 int dataReadFlag;
117
118 dataReadFlag = (2 == scanf(" %d %d ", &n, &m));
119 return (dataReadFlag);
120 } /* FUNCTION getInput */
121
122 void process()
123 {
124 /* FUNCTION process */
125 int tot = 0;
126 int i;
127
128 for (i=n; m>=i; i++)
129 {
130 /* add up number of valid houses */
131 tot = tot + list[i];
132 } /* add up number of valid houses */
133 printf("%d\n", tot);
134 } /* FUNCTION process */
135
136 int main()
137 {
138 /* main */
139 int moreToDo;
140
141 init();
142 moreToDo = getInput();
143 while (moreToDo)
144 {
145 /* while */
146 process();
147 moreToDo = getInput();
148 } /* while */
149
150 return EXIT_SUCCESS;
151 } /* main */
152