/home/toolbox/public_html/solutions/132/13291/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:
18 * Purpose: fun
19 * Problem:
20 */
21
22 /*
23 * This template reads data until a terminating value is reached.
24 */
25
26
27 int cnt;
28 long long tot[3];
29 long long h[3];
30 long long v[3];
31
32 void init()
33 {
34 /* FUNCTION init */
35 tot[0] = 0;
36 tot[1] = 0;
37 tot[2] = 0;
38 } /* FUNCTION init */
39
40 void dump()
41 {
42 /* FUNCTION dump */
43 } /* FUNCTION dump */
44
45 int getInput()
46 {
47 /* FUNCTION getInput */
48 int dataReadFlag;
49 int i;
50 long long tmp;
51
52 h[0] = 0;
53 h[1] = 0;
54 h[2] = 0;
55 v[0] = 0;
56 v[1] = 0;
57 v[2] = 0;
58 dataReadFlag = 0 < scanf(" %d ", &cnt);
59 if (dataReadFlag)
60 {
61 /* get rest */
62 for (i=0; cnt>i; i++)
63 {
64 /* get horizontal */
65 scanf(" %lld ", &tmp);
66 h[i%3] = h[i%3] + tmp;
67 } /* get horizontal */
68 for (i=0; cnt>i; i++)
69 {
70 /* get vertical */
71 scanf(" %lld ", &tmp);
72 v[i%3] = v[i%3] + tmp;
73 } /* get vertical */
74 } /* get rest */
75 return (dataReadFlag);
76 } /* FUNCTION getInput */
77
78 void process()
79 {
80 /* FUNCTION process */
81 int i;
82 int j;
83 int tmp;
84
85 init();
86 for (i=0; 3>i; i++)
87 {
88 /* horizontal */
89 for (j=0; 3>j; j++)
90 {
91 /* for each vertical */
92 tmp = (i + j) % 3;
93 tot[tmp] = tot[tmp] + h[i]*v[j];
94 } /* for each vertical */
95 } /* horizontal */
96 printf("%lld %lld %lld\n", tot[1], tot[2], tot[0]);
97
98 } /* FUNCTION process */
99
100 int main()
101 {
102 /* main */
103 int moreToDo;
104
105 init();
106 moreToDo = getInput();
107 while (moreToDo)
108 {
109 /* while */
110 process();
111 moreToDo = getInput();
112 } /* while */
113
114 return EXIT_SUCCESS;
115 } /* main */
116