Description
Bob is about to take a hot bath.
There are two taps to fill the bath: a hot water tap and a cold water tap. The cold water's temperature is t1, and the hot water's temperature is t2. The cold water tap can transmit any integer number of water units per second from 0 to x1, inclusive. Similarly, the hot water tap can transmit from 0 to x2 water units per second.
If y1 water units per second flow through the first tap and y2 water units per second flow through the second tap, then the resulting bath water temperature will be:
![](https://i-blog.csdnimg.cn/blog_migrate/53f5a0419be743602c90b2166625a643.png)
Bob wants to open both taps so that the bath water temperature was not less than t0. However, the temperature should be as close as possible to this value. If there are several optimal variants, Bob chooses the one that lets fill the bath in the quickest way possible.
Determine how much each tap should be opened so that Bob was pleased with the result in the end.
Input
You are given five integers t1, t2, x1, x2 and t0 (1 ≤ t1 ≤ t0 ≤ t2 ≤ 106, 1 ≤ x1, x2 ≤ 106).
Output
Print two space-separated integers y1 and y2 (0 ≤ y1 ≤ x1, 0 ≤ y2 ≤ x2).
Sample Input
10 70 100 100 25
99 33
300 500 1000 1000 300
1000 0
143 456 110 117 273
76 54
题意:
给出整数t1,t2,x1,x2,t0,和公式,(1 ≤ t1 ≤ t0 ≤ t2 ≤ 106, 1 ≤ x1, x2 ≤ 106).求满足(0 ≤ y1 ≤ x1, 0 ≤ y2 ≤ x2)此条件的y1,y2使得t最接近t0,但要保证t>t0.输出y1,y2.多种方案时输出最大的y1,y2.
题解:不4个特判必WA。不过这4个特判不太容易想全。
case 1:t1==t0 && t2!=t0 => y1=x1,y2=0
case 2:t2==t0 && t1!=t0 => y1=0,y2=x2
case 3:t1==t2 =>y1=x1,y2=x2
做法:
枚举y1,然后t2可以解出来。在选最小的,不过也有坑!见程序吧
case 4:非常难想到的是,当y1==0,方程解出y2=0此时显然不对,所以此种情况仍需处理。