-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUVa 11470 - Square Sums.cc
55 lines (42 loc) · 1.13 KB
/
UVa 11470 - Square Sums.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include <bits/stdc++.h>
using namespace std;
const int N = 100;
int g[N][N];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int c = 0;
while(true){
int n;
cin >> n;
if(n == 0)
break;
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
cin >> g[i][j];
}
}
int proc = 0;
vector <int> sums;
while(proc <= n / 2){
int sum = 0;
for(int i = proc; i < n - proc; i++){
if(proc != n - proc - 1)
sum += g[i][proc];
sum += g[i][n - proc - 1];
}
for(int j = proc + 1; j < n - proc - 1; j++){
if(proc + 1 != n - proc - 1)
sum += g[proc][j];
sum += g[n - proc - 1][j];
}
sums.push_back(sum);
proc++;
}
cout << "Case " << ++c << ": ";
for(int i = 0; i < ceil((1.0 * n) / 2); i++){
cout << sums[i] << (i + 1 == ceil((1.0 * n) / 2)? '\n':' ');
}
}
return 0;
}