/home/toolbox/public_html/solutions/132/13291/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
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 long long tmp;
32 long long num;
33 char xx;
34
35 void getnum()
36 {
37 /* FUNCTION getNum */
38 xx = getchar_unlocked();
39 while ((' ' == xx) || ('\n' == xx))
40 {
41 xx = getchar_unlocked();
42 }
43 num = xx - '0';
44 xx = getchar_unlocked();
45 while (('0' <= xx) && ('9' >= xx))
46 {
47 /* while */
48 /*
49 num = (num * 10) + x - '0';
50 num * 10 == (num * 8) + (num * 2)
51 num << 3 == num * 8
52 num << 1 == num * 2
53 */
54 num = (num << 3) + (num << 1) + xx - '0';
55 xx = getchar_unlocked();
56 } /* while */
57 } /* FUNCTION getNum */
58
59 int getInput()
60 {
61 /* FUNCTION getInput */
62 int dataReadFlag;
63 int i;
64
65 h[0] = 0;
66 h[1] = 0;
67 h[2] = 0;
68 v[0] = 0;
69 v[1] = 0;
70 v[2] = 0;
71 dataReadFlag = 0 < scanf(" %d ", &cnt);
72 if (dataReadFlag)
73 {
74 /* get rest */
75 for (i=0; cnt>i; i++)
76 {
77 /* get horizontal */
78 getnum();
79 h[i%3] = h[i%3] + num;
80 } /* get horizontal */
81 for (i=0; cnt>i; i++)
82 {
83 /* get vertical */
84 getnum();
85 v[i%3] = v[i%3] + num;
86 } /* get vertical */
87 } /* get rest */
88 return (dataReadFlag);
89 } /* FUNCTION getInput */
90
91 void process()
92 {
93 /* FUNCTION process */
94 int i;
95 int j;
96 int tmp;
97
98 tot[0] = 0;
99 tot[1] = 0;
100 tot[2] = 0;
101 for (i=0; 3>i; i++)
102 {
103 /* horizontal */
104 for (j=0; 3>j; j++)
105 {
106 /* for each vertical */
107 tot[(i+j)%3] += h[i]*v[j];
108 } /* for each vertical */
109 } /* horizontal */
110 printf("%lld %lld %lld\n", tot[1], tot[2], tot[0]);
111
112 } /* FUNCTION process */
113
114 int main()
115 {
116 /* main */
117 int moreToDo;
118
119 moreToDo = getInput();
120 while (moreToDo)
121 {
122 /* while */
123 process();
124 moreToDo = getInput();
125 } /* while */
126
127 return EXIT_SUCCESS;
128 } /* main */
129