CF1409B.Minimum Product

普及-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given four integers aa, bb, xx and yy. Initially, a≥xa \ge x and b≥yb \ge y. You can do the following operation no more than nn times:

  • Choose either aa or bb and decrease it by one. However, as a result of this operation, value of aa cannot become less than xx, and value of bb cannot become less than yy.

Your task is to find the minimum possible product of aa and bb (a⋅ba \cdot b) you can achieve by applying the given operation no more than nn times.

You have to answer tt independent test cases.

给你四个整数 aa、bb、xx 和 yy。初始时满足 a≥xa \ge x 且 b≥yb \ge y。你最多可以执行以下操作 nn 次:

  • 选择 aa 或 bb 中的一个,将其减 11。但操作后,aa 的值不能小于 xx,bb 的值不能小于 yy。

你的任务是:在最多执行 nn 次上述操作的前提下,求出 aa 与 bb 乘积(即 a⋅ba \cdot b)的最小可能值。

你需要回答 tt 个相互独立的测试用例。

输入格式

The first line of the input contains one integer tt (1≤t≤2⋅1041 \le t \le 2 \cdot 10^4) — the number of test cases. Then tt test cases follow.

The only line of the test case contains five integers aa, bb, xx, yy and nn (1≤a,b,x,y,n≤1091 \le a, b, x, y, n \le 10^9). Additional constraint on the input: a≥xa \ge x and b≥yb \ge y always holds.

输入的第一行包含一个整数 tt(1≤t≤2⋅1041 \le t \le 2 \cdot 10^4),表示测试用例的数量。随后是 tt 个测试用例。

每个测试用例仅有一行,包含五个整数 aa、bb、xx、yy 和 nn(1≤a,b,x,y,n≤1091 \le a, b, x, y, n \le 10^9)。输入的额外约束条件为:恒有 a≥xa \ge x 且 b≥yb \ge y。

输出格式

For each test case, print one integer: the minimum possible product of aa and bb (a⋅ba \cdot b) you can achieve by applying the given operation no more than nn times.

对于每个测试用例,输出一个整数:在最多执行 nn 次给定操作的前提下,所能达到的 aa 与 bb 的乘积(即 a⋅ba \cdot b)的最小可能值。

输入输出样例

  • 输入#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 bb three times and obtain 10⋅7=7010 \cdot 7 = 70.

In the second test case of the example, you need to decrease aa one time, bb one time and obtain 11⋅7=7711 \cdot 7 = 77.

In the sixth test case of the example, you need to decrease aa five times and obtain 5⋅11=555 \cdot 11 = 55.

In the seventh test case of the example, you need to decrease bb ten times and obtain 10⋅1=1010 \cdot 1 = 10.

在示例的第一个测试用例中,你需要将 bb 减少三次,得到 10⋅7=7010 \cdot 7 = 70。

在示例的第二个测试用例中,你需要将 aa 减少一次、bb 减少一次,得到 11⋅7=7711 \cdot 7 = 77。

在示例的第六个测试用例中,你需要将 aa 减少五次,得到 5⋅11=555 \cdot 11 = 55。

在示例的第七个测试用例中,你需要将 bb 减少十次,得到 10⋅1=1010 \cdot 1 = 10。

输入解题思路,AI测评打分。不知道怎么写?

首页