Typically, canvas appears static, thus we must resize images to fit it. However, this one is different. The canvas must be reshaped (with a set ratio) to fit the static-sized image.
You have a rectangular image with size $$$a \times b$$$ and a canvas of height and width ratio $$$m:n$$$. What would be the smallest canvas size that would fit the image?
Isn't this too simple?
Play a bit more. The image is rotated by $$$\theta$$$ degrees clockwise. Now, determine the smallest canvas size needed to fit the image using that ratio.
Note: $$$m, n$$$ may NOT be co-prime.
Each test contains multiple test cases. The first line contains the number of test cases T ($$$1\leq T \leq 10^5$$$). The description of the test cases follows.
Each test case consists of a single line containing five integers $$$a, b, m, n$$$, and $$$\theta$$$ ($$$1 \leq a,b,m,n \leq 10^9, 0 \leq \theta \leq 90$$$) — image size $$$a\times b$$$, canvas ratio $$$m:n$$$ and rotation of the image with the horizontal line.
For each test case, output two integers — the minimum size of the canvas X, Y — height and width. Answer must be integer value.
16 18 2 3 30
16 24
Dataset is huge, use faster I/O methods.
Name |
---|