A13692 | Minimum Product
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
You are given four integers $a$ , $b$ , $x$ and $y$ . Initially, $a \ge x$ and $b \ge y$ . You can do the following operation no more than $n$ times:
- Choose either $a$ or $b$ and decrease it by one. However, as a result of this operation, value of $a$ cannot become less than $x$ , and value of $b$ cannot become less than $y$ .
Your task is to find the minimum possible product of $a$ and $b$ ( $a \cdot b$ ) you can achieve by applying the given operation no more than $n$ times.
You have to answer $t$ independent test cases.
- Choose either $a$ or $b$ and decrease it by one. However, as a result of this operation, value of $a$ cannot become less than $x$ , and value of $b$ cannot become less than $y$ .
Your task is to find the minimum possible product of $a$ and $b$ ( $a \cdot b$ ) you can achieve by applying the given operation no more than $n$ times.
You have to answer $t$ independent test cases.
输入格式
The first line of the input contains one integer $t$ ( $1 \le t \le 2 \cdot 10^4$ ) — the number of test cases. Then $t$ test cases follow.
The only line of the test case contains five integers $a$ , $b$ , $x$ , $y$ and $n$ ( $1 \le a, b, x, y, n \le 10^9$ ). Additional constraint on the input: $a \ge x$ and $b \ge y$ always holds.
The only line of the test case contains five integers $a$ , $b$ , $x$ , $y$ and $n$ ( $1 \le a, b, x, y, n \le 10^9$ ). Additional constraint on the input: $a \ge x$ and $b \ge y$ always holds.
输出格式
For each test case, print one integer: the minimum possible product of $a$ and $b$ ( $a \cdot b$ ) you can achieve by applying the given operation no more than $n$ times.
输入输出样例
输入 #1
7 10 10 8 5 3 12 8 8 7 2 12343 43 4543 39 123212 1000000000 1000000000 1 1 1 1000000000 1000000000 1 1 1000000000 10 11 2 1 5 10 11 9 1 10
输出 #1
70 77 177177 999999999000000000 999999999 55 10
In the first test case of the example, you need to decrease $b$ three times and obtain $10 \cdot 7 = 70$ .
In the second test case of the example, you need to decrease $a$ one time, $b$ one time and obtain $11 \cdot 7 = 77$ .
In the sixth test case of the example, you need to decrease $a$ five times and obtain $5 \cdot 11 = 55$ .
In the seventh test case of the example, you need to decrease $b$ ten times and obtain $10 \cdot 1 = 10$ .
In the second test case of the example, you need to decrease $a$ one time, $b$ one time and obtain $11 \cdot 7 = 77$ .
In the sixth test case of the example, you need to decrease $a$ five times and obtain $5 \cdot 11 = 55$ .
In the seventh test case of the example, you need to decrease $b$ ten times and obtain $10 \cdot 1 = 10$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted