#P8811. [蓝桥杯 2022 国 C] 六六大顺

[蓝桥杯 2022 国 C] 六六大顺

Problem 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, 66 has been a lucky number since ancient times. Define a sequence A=(a1,a2,,ai,)A = (a_1,a_2,\cdots,a_i,\cdots), where a1=6,a2=66,,ai=10ai1+6a_1 = 6, a_2 = 66, \cdots, a_i = 10\cdot a_{i-1}+6.

Define another sequence B=(b1,b2,,bi,)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 nn terms of sequence BB. Can you help Xiao Lan?

Input Format

Input one line containing a positive integer nn.

Output Format

Output one line containing an integer, representing the sum of the first nn terms of sequence BB.

3
447948

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=44794836 + 4356 + 443556 = 447948.

Constraints and Notes

For 20%20\% of the testdata, 1n1001≤n≤100.

For 50%50\% of the testdata, 1n1051≤n≤10^5.

For all testdata, 1n1071\le n\le 10^7.

Lanqiao Cup 2022 National Contest, Group C, Problem H.

Translated by ChatGPT 5