CF1409B.Minimum Product
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given four integers a , b , x and y . Initially, a≥x and b≥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⋅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≤t≤2⋅104 ) — 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≤a,b,x,y,n≤109 ). Additional constraint on the input: a≥x and b≥y always holds.
输出格式
For each test case, print one integer: the minimum possible product of a and b ( a⋅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⋅7=70 .
In the second test case of the example, you need to decrease a one time, b one time and obtain 11⋅7=77 .
In the sixth test case of the example, you need to decrease a five times and obtain 5⋅11=55 .
In the seventh test case of the example, you need to decrease b ten times and obtain 10⋅1=10 .