Problem p04011 - Generation 1

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 some quantity or threshold.
An integer \(X\) (1 ≤ \(X\) ≤ 10000), greater than an integer \(Y\) (1 ≤ \(Y\) < \(X\)).

### Example Input:

```
15
3
10000
9000
```

### Function Signature:
Write a function f(N, K, X, Y) that takes in the input.
```python
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 help you write a test case generator for the given problem statement. Here is the Python code that generates random test cases based on the constraints provided:

```python
import random

def tcgen():
    N = random.randint(1, 10000)
    K = random.randint(1, 10000)
    
    # Ensure X > Y
    Y = random.randint(1, 9999)
    X = random.randint(Y + 1, 10000)
    
    return N, K, X, Y

# Example of how to use the test case generator
if __name__ == "__main__":
    for _ in range(10):  # Generate 10 test cases as an example
        test_case = tcgen()
        print(f"N: {test_case[0]}, K: {test_case[1]}, X: {test_case[2]}, Y: {test_case[3]}")
```

This generator ensures that each test case adheres to the problem's constraints:

- \(1 \leq N, K \leq 10000\)
- \(1 \leq Y < X \leq 10000\)

You can run this script to generate multiple test cases for your problem. Each test case consists of the values for \(N\), \(K\), \(X\), and \(Y\). Here's an example of how you might use the generated values in your code:

```python
def calculate_total_accommodation_fee(N, K, X, Y):
    if N <= K:
        return N * X
    else:
        return K * X + (N - K) * Y

# Example of how to use the generated test cases
if __name__ == "__main__":
    for _ in range(10):  # Generate 10 test cases as an example
        N, K, X, Y = tcgen()
        total_fee = calculate_total_accommodation_fee(N, K, X, Y)
        print(f"N: {N}, K: {K}, X: {X}, Y: {Y}, Total Fee: {total_fee}")
```

This way, you can test the function `calculate_total_accommodation_fee` with randomly generated test cases to ensure it works correctly under various scenarios.

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