#C10267. Pyramid Sum and Last Level Product
Pyramid Sum and Last Level Product
Pyramid Sum and Last Level Product
In this problem, you are given the height of a number pyramid. The pyramid is constructed in such a way that each level i (for 1 ≤ i ≤ n) contains the number i repeated i times. You need to calculate two values:
-
The total sum of all numbers in the pyramid, which can be expressed using the formula [ \sum_{i=1}^{n} i^2, ] that is the sum of the squares of the first n natural numbers.
-
The product of all the numbers in the last level of the pyramid. Since the last level consists only of the number n repeated n times, this product is given by [ n^n. ]
For example, if n = 4, the pyramid is:
Level 1: 1 Level 2: 2 2 Level 3: 3 3 3 Level 4: 4 4 4 4
The total sum is 1^2 + 2^2 + 3^2 + 4^2 = 30, and the product of the last level is 4^4 = 256.
Your task is to read an integer from standard input and output the two computed values separated by a space. Make sure that your program reads from stdin and writes to stdout.
inputFormat
The input consists of a single line containing an integer n (1 ≤ n ≤ 10^? based on constraints), which represents the height of the pyramid.
outputFormat
Output two numbers separated by a space: the first number is the total sum of the squares of numbers from 1 to n, i.e., (\sum_{i=1}^{n} i^2), and the second is (n^n), the product of the numbers on the last level.## sample
1
1 1