/home/toolbox/public_html/solutions/114/11461/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
10 #define TRUE (1 == 1)
11 #define FALSE (1 != 1)
12
13 #define DEBUG if (FALSE)
14
15 /*
16 * Author: Isaac Traxler
17 * Date: 2015-09-08
18 * Purpose: fun
19 * Problem: 11461
20 */
21
22 /*
23 * This template reads data until a terminating value is reached.
24 */
25
26 #define MAX_SQUARES 333
27
28 int a;
29 int b;
30 int squares[MAX_SQUARES];
31 int squareCnt = 1;
32
33 void init()
34 {
35 /* FUNCTION init */
36 int i;
37
38 squares[0] = 1;
39 for (i=2; i<MAX_SQUARES; i++)
40 {
41 /* calculate square */
42 squares[squareCnt++] = i*i;
43 } /* calculate square */
44 DEBUG printf("SquaneCnt = %d\n", squareCnt);
45 } /* FUNCTION init */
46
47 void dump()
48 {
49 /* FUNCTION dump */
50 } /* FUNCTION dump */
51
52 int getInput()
53 {
54 /* FUNCTION getInput */
55 int dataReadFlag;
56
57 scanf(" %d %d ", &a, &b);
58 dataReadFlag = (0 != a);
59 return (dataReadFlag);
60 } /* FUNCTION getInput */
61
62 void process()
63 {
64 /* FUNCTION process */
65 int i;
66 int cnt = 0;
67
68 for (i=0; a>squares[i]; i++) {}; /* skip all numbers less than a */
69 while (b >= squares[i])
70 {
71 /* found one */
72 cnt++;
73 i++;
74 } /* found one */
75 printf("%d\n", cnt);
76 } /* FUNCTION process */
77
78 int main()
79 {
80 /* main */
81 int moreToDo;
82
83 init();
84 moreToDo = getInput();
85 while (moreToDo)
86 {
87 /* while */
88 process();
89 moreToDo = getInput();
90 } /* while */
91
92 return EXIT_SUCCESS;
93 } /* main */
94