A Nice Plot
All submissions for this problem are available.
Chef is going to setup his JEE Coaching Classes. He has bought a plot of width w and height h. Chef's numerologist Alice is not happy with the dimensions of his plot. A plot is said to be nice if its width:height is exactly x:y.
Chef wants to transform his plot into a 'nice' plot because he cannot take a risk with his new Coaching classes. He already has invested a lot of money so he will not buy new plot any more. Thus, he need to resize the plot such that it becomes nice and its area is maximum.
Help Chef in resizing the plot.
A single integer T denoting the no of test cases. Next T lines contain 4 space separated integers w,h,x,y.
For each test case print 2 space separated integers denoting the width and height of the maximum nice plot. In case no answer exists output 0 0
- 1 <= T <= 40
- 1 <= w,h,x,y <= 109
Input: 2 6 5 3 2 6 4 27 31 Output: 6 4 0 0
|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, CLOJ, COB, FS|
Fetching successful submissions