#AJ2001. Numeral Triangles(初级)
Numeral Triangles(初级)
Description
Construct a Numeral Triangle according to the following rules. You will be given three positive integers: , a starting number; , a delta (the amount by which to increase each number in the triangle); and the number of rows.
- The first row contains the number .
- Each of the next rows has one more number than the previous row.
- Each number in the triangle is more than the previous number in the triangle.
- Before putting a number in the triangle, it is transformed to a single digit. That is, if the number is more than one digit, replace it by the sum of the digits, repeating until the sum is one digit (for example, ).
Here are two examples of Numeral Triangles:
start=2, delta=3, rows=5
2
5 8
2 5 8
2 5 8 2
5 8 2 5 8
start=221, delta=2, rows=4
5
7 9
2 4 6
8 1 3 5
Input Format
There are 5 lines of data. Each line has 3 positive integers, , , and . The numbers are separated by spaces and each is less than 100,000.
Output Format
For each line of data, print the sum of all numbers on the th line of the Numeral Triangle.
Explanation
Example 1:
Input 2 3 5
- The numbers on row 5 are 5, 8, 2, 5, 8.
- Sum = .
Example 2:
Input 221 2 4
- . .
- The numbers on row 4 are 8, 1, 3, 5.
- Sum = .
2 3 5
28
221 2 4
17
184 231 35
140
71 5 27
135
1 24 100
397
Related
In following homework: