Problem p04011 - Generation 2

Orig Description

Score : 100 points
Problem StatementThere is a hotel with the following accommodation fee:
X yen (the currency of Japan) per night, for the first K nights
Y yen per night, for the (K+1)-th and subsequent nights
Tak is staying at this hotel for N consecutive nights.
Find his total accommodation fee.
Constraints
1 \leq N, K \leq 10000
1 \leq Y < X \leq 10000
N,\,K,\,X,\,Y are integers.
InputThe input is given from Standard Input in the following format:
N
K
X
Y
OutputPrint Tak's total accommodation fee.
Sample Input 15
3
10000
9000
Sample Output 148000
The accommodation fee is as follows:
10000 yen for the 1-st night
10000 yen for the 2-nd night
10000 yen for the 3-rd night
9000 yen for the 4-th night
9000 yen for the 5-th night
Thus, the total is 48000 yen.
Sample Input 22
3
10000
9000
Sample Output 220000

Extracted Specification

An integer N (1 ≤ N ≤ 10000), representing some quantity or size.
An integer K (1 ≤ K ≤ 10000), representing another quantity or size.
An integer X (1 ≤ X ≤ 10000), representing a cost or value.
An integer Y (1 ≤ Y < X ≤ 10000), representing another cost or value.

### Example Input:

```
15
3
10000
9000
```

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

Test Case Generator

Sure, I can write a test case generator for the problem statement you provided. Here is a Python function that generates random test cases for the given problem:

```python
import random

def tcgen():
    # Generate random values for N and K within the range [1, 10000]
    N = random.randint(1, 10000)
    K = random.randint(1, 10000)
    
    # Generate random values for X and Y such that 1 <= Y < X <= 10000
    Y = random.randint(1, 9999)
    X = random.randint(Y + 1, 10000)
    
    return N, K, X, Y

# Example of generating a test case and printing it
N, K, X, Y = tcgen()
print(f"Generated Test Case:\nN: {N}\nK: {K}\nX: {X}\nY: {Y}")
```

This function generates random values for `N`, `K`, `X`, and `Y` adhering to the constraints specified in the problem statement. Each time you call `tcgen()`, it will produce a new set of values.

### Explanation:

- **N**: The number of consecutive nights Tak is staying at the hotel, randomly chosen from 1 to 10000.
- **K**: The number of nights for which the accommodation fee is `X` yen per night, randomly chosen from 1 to 10000.
- **X**: The fee per night for the first `K` nights, chosen randomly such that it is greater than `Y` and less than or equal to 10000.
- **Y**: The fee per night for the `(K+1)`-th and subsequent nights, chosen randomly such that it is less than `X` and at least 1.

This generator respects the constraints and will help you create varied and comprehensive test cases for your problem.

Extract Arguments

def extract_arguments(fh):
    N = int(fh.readline().strip())
    K = int(fh.readline().strip())
    X = int(fh.readline().strip())
    Y = int(fh.readline().strip())
    return N, K, X, Y