[BOJ 14542] Outer Triangle Sum

View as PDF

Submit solution

Points: 1
Time limit: 10.0s
Memory limit: 512M

Problem types
Allowed languages
Assembly, Awk, C, C++, Java, Pascal, Perl, Python, Sed, Text

You are to find the sum of the outer number of an isosceles right triangle.</p>

For example, for n = 5 the isosceles right triangle grid are filled with non-negative integers that are less than 100:

5   
1   8 
9   6  1 
2   7  2  6 
3   5  7  8  9

The sums of the outer integers are calculated as below:

sum = 5 + 1 + 9 + 2 + 3 + 5 + 7 + 8 + 9 + 6 + 1 + 8 = 64

입력 형식

The input consists of a few test cases. For each test case, the first line of input is a positive integer n (n <= 10) that determines the dimension of the triangle. Each of the next n lines contains 1 to n integers respectively that will fill the isosceles right triangle. Input is terminated by a case where n is 0.

출력 형식

Each line of output will start with “Case #:” where # is replaced by the case number. Then you have to output the sum of the outer numbers of the triangle.

예제 입력

5
5   
1 8  
9 6 1  
2 7 2 6  
3 5 7 8 9
3
1 
2 3
4 5 6
0

예제 출력

Case #1:64 
Case #2:21

Comments

There are no comments at the moment.