Problem p02621 - Generation 3

Orig Description

Score : 100 points
Problem StatementGiven an integer a as input, print the value a + a^2 + a^3.
Constraints
1 \leq a \leq 10
a is an integer.
InputInput is given from Standard Input in the following format:
a
OutputPrint the value a + a^2 + a^3 as an integer.
Sample Input 12
Sample Output 114
When a = 2, we have a + a^2 + a^3 = 2 + 2^2 + 2^3 = 2 + 4 + 8 = 14.
Print the answer as an input. Outputs such as 14.0 will be judged as incorrect.
Sample Input 210
Sample Output 21110

Extracted Specification

An integer X (1 ≤ X ≤ 10), representing some quantity.

### Example Input:

```
2
```

### Function Signature:
Write a function f(X) that takes in the input.
def f(X: int):
    ''' 
    X: an integer
    '''

Test Case Generator

Sure! Here's a test case generator for the given problem statement:

### Problem Statement: Sum of Powers

**Description**

Given an integer \( a \), the task is to calculate and print the value \( a + a^2 + a^3 \).

**Constraints**

- \( 1 \leq a \leq 10 \)
- \( a \) is an integer.

**Input**

Input is given from Standard Input in the following format:
```
a
```

**Output**

Print the value \( a + a^2 + a^3 \) as an integer.

**Examples**

_Input_
```
2
```

_Output_
```
14
```

_Input_
```
10
```

_Output_
```
1110
```

**Explanation**

In the first example, the value of \( a \) is 2, so the result is calculated as \( 2 + 2^2 + 2^3 = 2 + 4 + 8 = 14 \).

In the second example, the value of \( a \) is 10, so the result is calculated as \( 10 + 10^2 + 10^3 = 10 + 100 + 1000 = 1110 \).

### Test Case Generator

Here's the Python code for the test case generator:

```python
import random

def tcgen():
    # Generate a random integer a in the range 1 to 10
    a = random.randint(1, 10)
    
    # Return the generated test case
    return a

# Example usage:
if __name__ == "__main__":
    # Generate a test case
    a = tcgen()
    
    # Print the test case
    print(a)
    
    # Calculate the expected output
    result = a + a**2 + a**3
    
    # Print the expected output
    print(result)
```

This `tcgen` function will generate random test cases within the constraints provided. The main block demonstrates how to use the generator and print both the input and the expected output for verification.

Extract Arguments

def extract_arguments(fh):
    a = int(fh.readline().strip())
    return a