P8811 [Lqiao Cup 2022 National C] Everything Goes Smoothly with Sixes
Description
“六六大顺” originally refers to the 6th day of the 6th month in the lunar calendar. It is often used as a blessing for middle-aged people: a happy family, smooth work, success in career, and good health. It comes from the *Zuo Zhuan*: “君义,臣行,父慈,子孝,兄爱,弟敬,此数者累谓六顺也。”
In China, $6$ has been a lucky number since ancient times. Define a sequence $A = (a_1,a_2,\cdots,a_i,\cdots)$, where $a_1 = 6, a_2 = 66, \cdots, a_i = 10\cdot a_{i-1}+6$.
Define another sequence $B = (b_1,b_2,\cdots,b_i,\cdots)$, where $b_1 = 6 \times 6, b_2 = 66\times66, \cdots, b_i = a_i \times a_i$.
Now Xiao Lan wants to know the sum of the first $n$ terms of sequence $B$. Can you help Xiao Lan?
Input Format
Input one line containing a positive integer $n$.
Output Format
Output one line containing an integer, representing the sum of the first $n$ terms of sequence $B$.
Explanation/Hint
**Sample Explanation**
$b_1 = 6×6 = 36,b_2 = 66×66 = 4356,b_3 = 666×666 = 443556$, so the sum of the first three terms is $36 + 4356 + 443556 = 447948$.
**Constraints and Notes**
For $20\%$ of the testdata, $1≤n≤100$.
For $50\%$ of the testdata, $1≤n≤10^5$.
For all testdata, $1\le n\le 10^7$.
Lanqiao Cup 2022 National Contest, Group C, Problem H.
Translated by ChatGPT 5