Chef And Cupboards
All submissions for this problem are available.Chef’s wife asked Chef to build a cupboard of the following specifications. **Assume that the width of the base is $X$. Then the Length of the base should not exceed $(A-X)$ and the Height of the cupboard should not exceed $(B-X)$. Also The Volume of the Cupboard should be maximum.** Chef’s wife gives him the two integers $A$ and $B$ and asks him to find an integer $X$ such that the Volume is maximum. Since Chef is trying out a new recipe, Chef asks you to help him find $X$. If there are multiple such $X$ then find the smaller one. **Note: All dimensions should be strictly positive integers.** ###Input: - First line will contain $T$, number of testcases. Then the testcases follow. - Each testcase contains of a single line of input, two integers $A, B$. ###Output: For each testcase, output in a single line the value of $X$ and the maximum volume. ###Constraints - $1 \leq T \leq 500000$ - $2 \leq A,B \leq 50000$ ###Subtasks - 30 points : $2 \leq A,B \leq 500$ - 70 points : $2 \leq A,B \leq 50000$ ###Sample Input: 1 378 299 ###Sample Output: 111 5571756
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.