Posted by Anonymous on Thursday, March 17, 2011 at 6:06pm.
A series of streams run down the side of a mountain. The mountainside is very rocky so
the streams split and rejoin many times. At the foot of the mountain, several streams
emerge as rivers. Your job is to compute how much water flows in each river.
At any given elevation there are n streams, labelled 1 to n from left-to-right. As we
proceed down the mountainside, one of the streams may split into a left fork and a right
fork, increasing the total number of streams by 1, or two streams may rejoin, reducing the
total number of streams by 1. After a split or a rejoining occurs, the streams are
renumbered consecutively from left-to-right. There is always at least one stream and
there are never more than 100 streams.
The first line of input contains n, the initial number of streams at some high altitude. The
next n lines give the flow in each of the streams from left-to-right. Proceeding down the
mountainside, several split or rejoin locations are encountered. For each split location,
there will be three lines of input;
a line containing 99 (to indicate a split)
a line containing the number of the stream that is split
a line containing a number between 0 and 100, the percentage of flow from the split
stream that flows to the left fork. (The rest flows to the right fork).
For each join location, there will be two lines of input;
a line containing 88 (to indicate a join)
a line containing the number of the stream that is rejoined with the stream to its right
The flow from both joined streams is combined. After the last split or join location will
a single line containing 77 (to indicate end of input)
Your job is to determine how many streams emerge at the foot of the mountain and what
the flow is in each. Your output is a sequence of real numbers, rounded to the nearest
integer, giving the flow in rivers 1 through n.
Sample Input (Input file : brooks.in)
Output for Sample Input (Output file : brooks.out)
can you help me with this one...i don't understand it.
Answer this Question
probability - out of 250 students interviewed at a community college, 90 were ...
statistics - The director of the campus-computing center did a study to ...
brooks - A 3.90 kg block is in equilibrium on an incline of 24.1◦. The ...
computer - What does tenure track, part time instructor of computer science does...
Grammar - Write each pronoun, and write whether it is a subject pronoun or and ...
Math - Mr. Evans, Mrs Brooks and Mr. Soto are carpentersfrom Durham. They made ...
CSC 111 Intruduction to Computer Science - What does it imply to pursue a ...
English - Let's write down what you can do with the computer. 1. I use the ...
computer science - write a program to select the classes that you are taking(Ex...
science - calculate the ratio of wavelength o mth line of lyman series and ...