
ZOJ Problem Set  2519
You are going to receive a big big birthday cake from the Algorithm City of Mathematics (ACM). The rectangle cake is so big that everyone in the city can come to share a piece with you. But first, as the birthday boy/girl, you have to pass a test. You are standing at the center of the city square, and are given a magic knife that can be stretched as long as you like. The cake is placed in front of you and the four sides of it are parallel to either the WestEast or the SouthNorth axes. Given two positive integers a and b, you are supposed to cut the cake into two pieces so that the cakes to your lefthandside and that to your righthandside are in the proportion of a:b. Figure 1 shows a way to cut the cake into 1:1, and Figure 2 illustrates how to cut it into 1:2. Input Output 1 1 3 3 1 1 2 3 1 1 1 2Sample Output: 1.00 Infinity Author: CHEN, Yue Source: CYJJ's Funny Contest #2, Relaxing on Math 