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 West-East or the South-North axes. Given two positive integers a and b, you are supposed to cut the cake into two pieces so that the cakes to your left-hand-side and that to your right-hand-side 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.
1 1 3 3 1 1 -2 -3 1 -1 1 2Sample Output:
Author: CHEN, Yue
Source: CYJJ's Funny Contest #2, Relaxing on Math