408107: GYM102986 C Spice Ratios

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

C. Spice Ratiostime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

Kumar thinks he has perfected his recipe for the best chicken and rice dish in the world, Hyderabadi Chicken Biryani. The weekend is fast approaching and his restaurant will be swarmed with to-go orders soon. In order to get ahead of the rush, he plans on cooking a huge batch of his biryani. His recipe calls for $$$s$$$ tablespoons of spice powder for every $$$t$$$ tablespoons of turmeric he uses. In his pantry, he currently has $$$m$$$ tablespoons of spice powder and $$$n$$$ tablespoons of turmeric. He asks you to figure out the amount of spice powder and turmeric to use such that he can maximize the amount of biryani made while still maintaining his recipe's optimal ratio and using integer amounts of each (if it is not possible for him to maintain the ratio with integer amounts of each, output 0 0).

Input

The first and only line of input will contain $$$4$$$ space-separated integers $$$m, n, s$$$ and $$$t$$$ representing Kumar's starting amount of spice powder, Kumar's starting amount of turmeric, Kumar's wanted amount of spice powder in his optimal ratio, and Kumar's wanted amount of turmeric in his optimal ratio, respectively. All quantities are in tablespoons and it is guaranteed that $$$1 \leq m,n,s,t \leq 2 \cdot 10^{9}$$$.

Output

Output two integers, separated by a space, representing the integer amount of spice powder and the integer amount of turmeric that Kumar can use while maintaining his optimal ratio in order to make the maximum amount of biryani. If he cannot make his optimal ratio from his starting amounts, output 0 0.

ExamplesInput
90 60 3 2
Output
90 60
Input
1920 1200 32 18
Output
1920 1080

加入题单

上一题 下一题 算法标签: