/home/toolbox/public_html/solutions/126/12620/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 <stdlib.h>
7 #include <math.h>
8 #include <stdint.h>
9
10 #define TRUE (1 == 1)
11 #define FALSE (1 != 1)
12
13 #define DEBUG if (FALSE)
14
15 /* fprintf(stderr, "functionName: message", varslist); */
16
17 /*
18 * Author: Isaac Traxler
19 * Date: 2015-10-04
20 * Purpose: fun
21 * Problem: 12620
22 */
23
24 /*
25 * This template reads data a specified number of times.
26 */
27
28 int numberOfTimes;
29 int M;
30 int N;
31 int ans[100];
32
33 int fib(int a, int b)
34 {
35 /* FUNCTION fib */
36
37 return ((a+b) % 100);
38 } /* FUNCTION fib */
39
40 void dump()
41 {
42 /* FUNCTION dump */
43 int i;
44
45 for (i=0; i<100; i++)
46 {
47 /* for i */
48 if (0 == ans[i])
49 {
50 printf("%d ", i);
51 }
52 } /* for i */
53 printf("\n");
54 } /* FUNCTION dump */
55
56 void dump1()
57 {
58 /* FUNCTION dump1 */
59 int i;
60
61 for (i=0; i<100; i++)
62 {
63 /* for i */
64 printf("%d: %d\n", i, ans[i]);
65 } /* for i */
66 } /* FUNCTION dump1 */
67
68 void init()
69 {
70 /* FUNCTION init */
71 int i;
72
73 scanf("%d ", &numberOfTimes);
74 ans[1] = 1;
75 ans[2] = 1;
76 for (i=3; i<100; i++)
77 {
78 /* for i */
79 ans[i] = fib(ans[i-1], ans[i-2]);
80 DEBUG printf("%d: ", i);
81 DEBUG dump();
82 } /* for i */
83 ans[0] = fib(ans[98], ans[99]);
84 DEBUG dump1();
85 } /* FUNCTION init */
86
87 void getInput()
88 {
89 /* FUNCTION getInput */
90 scanf(" %d %d ", &M, &N);
91 } /* FUNCTION getInput */
92
93 int sum(int m, int n)
94 {
95 /* FUNCTION sum */
96 int i;
97 int tot = 0;
98
99 for (i=m; i<=n; i++)
100 {
101 /* for i */
102 tot = tot + ans[i];
103 } /* for i */
104 return tot;
105 } /* FUNCTION sum */
106
107 void process()
108 {
109 /* FUNCTION process */
110 int i;
111 int m;
112 int n;
113 int tot = 0;
114
115 m = M % 100;
116 n = N % 100;
117 if (m <= n)
118 {
119 /* sequence still normal */
120 tot = sum(m,n);
121 } /* sequence still normal */
122 else
123 {
124 /* first and last */
125 tot = sum(0,m) + sum(n, 99);
126 } /* first and last */
127 printf("%d\n", tot);
128
129 } /* FUNCTION process */
130
131 int main()
132 {
133 /* main */
134 int i;
135
136 init();
137 for (i=0; i<numberOfTimes; i++)
138 {
139 /* while */
140 getInput();
141 process();
142 } /* while */
143
144 return EXIT_SUCCESS;
145 } /* main */
146
147