#GD0000172. Tích nhỏ nhất (Minimum Product)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Tích nhỏ nhất (Minimum Product)
Minimum Product
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
You are given two positive integers . You may perform at most operations. Each operation decreases either or by exactly . Throughout the process, and must remain true: neither value may be reduced below its respective lower bound.
You may perform fewer than operations. Find the minimum possible product after the operations.
Input
The only line contains five integers in this order; are the lower bounds and is the maximum number of operations.
Output
Print one integer: the minimum product achievable using at most operations.
Subtasks
- Subtask 1 (20 points): ; and .
- Subtask 2 (30 points): ; and .
- Subtask 3 (50 points): ; and .
Examples
Input
10 10 8 5 3
Output
70
Explanation
Initially . We may lower by at most and by at most . Spending all three operations on yields . Spending two on and one on yields , which is larger. Therefore the minimum is .