B. Minimum Product SOLUTIONS Codeforces Round #667 (Div. 3)

Minimum Product SOLUTION

You are given four numbers a, b, x and y. At first, a≥x and b≥y. You can do the accompanying activity close to n times: 
 
Pick either an or b and lessening it by one. In any case, because of this activity, estimation of a can’t turn out to be not as much as x, and estimation of b can’t turn out to be not as much as y. 
 
Your assignment is to locate the base conceivable result of an and b (a⋅b) you can accomplish by applying the given activity close to n times. 
 
You need to answer t free experiments. 
 
Info 
 
The main line of the information contains one number t (1≤t≤2⋅104) — the quantity of experiments. At that point t experiments follow. 
 
The main line of the experiment contains five whole numbers a, b, x, y and n (1≤a,b,x,y,n≤109). Extra limitation on the info: a≥x and b≥y consistently holds. 
 
Yield 
 
For each experiment, print one whole number: the base conceivable result of an and b (a⋅b) you can accomplish by applying the given activity close to n times. 
 
Model 
 
inputCopy 
 
 
10 8 5 3 
 
12 8 7 2 
 
12343 43 4543 39 123212 
 
1000000000 1 
 
1000000000 1 1000000000 
 
10 11 2 1 5 
 
10 11 9 1 10 
 
outputCopy 
 
70 
 
77 
 
177177 
 
999999999000000000 
 
999999999 
 
55 
 
10 
 
Note 
 
In the primary experiment of the model, you have to diminish b multiple times and acquire 10⋅7=70. 
 
In the subsequent experiment of the model, you have to diminish a one time, b one time and get 11⋅7=77. 
 
In the 6th experiment of the model, you have to diminish a five times and acquire 5⋅11=55. 
 
In the seventh experiment of the model, you have to diminish b multiple times and acquire 10⋅1=10
 

Leave a Comment