#P8811. The Six-Six Sequence Sum
The Six-Six Sequence Sum
The Six-Six Sequence Sum
In Chinese culture, the number 6 is considered lucky and symbolizes smooth progress. The phrase "六六大顺" originally referred to the sixth day of the sixth lunar month, and it is used to wish success and happiness in family, work, and life. It is derived from the saying in Zuo Zhuan: "君义,臣行,父慈,子孝,兄爱,弟敬,此数者累谓六顺也."
We define a sequence \(A = (a_1, a_2, \dots, a_i, \dots)\) as follows:
[ a_1 = 6, \quad a_i = 10\times a_{i-1} + 6 \quad (i \ge 2). ]
The sequence \(A\) is: 6, 66, 666, ... . Based on this, define another sequence \(B = (b_1, b_2, \dots, b_i, \dots)\) by
[ b_i = a_i \times a_i \quad (i \ge 1). ]
Your task is to compute the sum of the first \(n\) terms of sequence \(B\):
[ S = \sum_{i=1}^{n} b_i = \sum_{i=1}^{n} a_i^2. ]
Note: Although the numbers involved can grow very quickly, the input constraints for this problem will be such that the results can be computed using arbitrary precision arithmetic available in your programming language.
inputFormat
The input consists of a single integer \(n\) (\(1 \le n \le 100\)), which represents the number of terms to sum.
outputFormat
Output a single number, which is the sum of the squares of the first \(n\) terms of sequence \(A\).
sample
1
36