/home/toolbox/public_html/solutions/132/13287/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 <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: 2018-10-23
20 * Purpose: fun
21 * Problem: 13287
22 */
23
24 /*
25 * This template reads data a specified number of times.
26 */
27
28 int moreToDo;
29 int width;
30 int lgth;
31 int tot;
32
33 void init()
34 {
35 /* FUNCTION init */
36 } /* FUNCTION init */
37
38 void dump()
39 {
40 /* FUNCTION dump */
41 } /* FUNCTION dump */
42
43 int getInput()
44 {
45 /* FUANCTION getInput */
46 int i;
47 int x;
48 int y;
49 int cnt;
50 int moreToDo;
51
52 moreToDo = 0 < (scanf(" %d ", &width));
53 if (moreToDo)
54 {
55 /* read width -- so get rest of data */
56 tot = 0;
57 scanf(" %d ", &cnt);
58 DEBUG printf("(width = %d) (cnt = %d) (tot = %d)\n", width, cnt, tot);
59 for (i=0; cnt>i; i++)
60 {
61 /* for */
62 scanf(" %d %d ", &x, &y);
63 tot = tot + (x * y);
64 } /* for */
65 DEBUG printf("(width = %d) (cnt = %d) (tot = %d)\n", width, cnt, tot);
66 } /* read width -- so get rest of data */
67 return moreToDo;
68 } /* FUNCTION getInput */
69
70 void process()
71 {
72 /* FUNCTION process */
73 lgth = tot / width;
74 printf("%d\n", lgth);
75 } /* FUNCTION process */
76
77 int main()
78 {
79 /* main */
80 int i;
81
82 moreToDo = getInput();
83 while (moreToDo)
84 {
85 /* while */
86 process();
87 moreToDo = getInput();
88 } /* while */
89
90 return EXIT_SUCCESS;
91 } /* main */
92
93