Cards
Time Limit: 2 Seconds Memory Limit: 65536 KB
You have got a set of cards. On each card an integer between 1 to m is written. The number of cards that have number i written on their side is equal to ni.
You shuffle the cards and distribute them among m bins so that i-th bin receives ni cards. In each bin cards are stacked on top of each other. All possible distributions of cards are equally likely to occur.
We call a distribution of cards nice with respect to i-th bin, if it has the following property. Starting with i-th bin, in each step you pick (and remove) the topmost card from it. The number written on the card specifies the bin from which you should pick the next card. You keep picking cards in this way until you cannot pick any more cards. The distribution is nice if you can remove all the cards following these instructions. In other words, after the last move there should not be any cards remained.
He is curious to find the probability that a random distribution of cards is nice with respect to first bin, and also with respect to a random bin. Put differently, can we remove all the cards if we pick the first card from the first bin? What if we choose the starting bin uniformly at random?
Input
Input contains at most 150 tests. In the first line of each test there will be an integer m (2 ≤ m ≤ 1000). Parameter m is the number of bins that the cards are distributed among and also it is the greatest number written on a card.
Next line will contain m integers ni (1 ≤ ni ≤ 109). Parameter ni is the number of cards that i-th bin receives and also it is the number of cards that number i is written on them.
Input terminates with m=0.
Output
For each test you should output the probabilities that a random distribution of cards is nice with respect to first bin followed by the answer to the same question with respect to a random bin. These two numbers should be separated with a single space and should be formatted as irreducible fraction p/q such that greatest common divisor of p and q is equal to 1.
Sample Input
2 1 1 3 10920 2184 6552 0
Sample Output
1/2 1/2 1/3 5/9Submit
Source: 4th Kashan University's ACM Contest