Computer Science

posted by .

Babbling Brooks
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 :
Output for Sample Input (Output file : brooks.out)
5 55
can you help me with this one...i don't understand it.

Respond to this Question

First Name
School Subject
Your Answer

Similar Questions

  1. science

    What kind of streams form v-shaped valleys?
  2. earth

    Sometimes streams and rivers run in fairly straight lines. Sometimes, they meander or curve and wander. What is your idea about how faster water affects the shape of a stream or river?
  3. physics

    Water is shooting at the same speed out of the three tubes placed on the ground at different angles of 60°, 45°, and 30° to the horizon. Find the ratio of the greatest heights the streams can reach and the ratio of distances from …
  4. 6th grade science

    can streams run underground. Can they start above ground and run nunderground. PLease help me, I am so so stuck.
  5. 6th grade science

    A factory is found to be polluting a stream high up in the Rocky Mountains. The factory owner says that this is not aproblem because the stream is very small. Why do you disagree/agree with the owner. I disagree. who gives a crap if …
  6. English

    in shadowy valleys and rocky ravine where tiny rills meet with rushing streams need it description
  7. science

    Low water flows are a common problem for ecosystems in semi-urban streams. Should the suggestion of using domestic drinking water supplies to increase water flows in the streams be adopted?
  8. Science

    Watershed's affect our environment because without watershed's we wouldn't be able to transport water to nearby lakes,streams, rivers, etc. The water comes from precipitation that falls on to a certain land called watershed and then …
  9. Social Studies

    What are the causes of the water pollution that threaten South Asia today?
  10. Science

    About what percent of all of Earth's fresh water is found in ground water, streams, lakes, and rivers?

More Similar Questions