1385 问题 E: Just Pour the Water

时间限制: 1s 内存限制: 32MB 提交: 14 解决: 8
题目描述
Shirly is a very clever girl. Now she has two containers (A and B), each with some water. Every minute,
she pours half of the water in A into B, and simultaneous pours half of the water in B into A. As the
pouring continues, she finds it is very easy to calculate the amount of water in A and B at any time. It is
really an easy job :).
But now Shirly wants to know how to calculate the amount of water in each container if there are more
than two containers. Then the problem becomes challenging.
Now Shirly has N (2 <= N <= 20) containers (numbered from 1 to N ). Every minute, each container is
supposed to pour water into another K containers ( K may vary for different containers). Then the water
will be evenly divided into K portions and accordingly poured into anther K containers. Now the question
is: how much water exists in each container at some specified time?
For example, container 1 is specified to pour its water into container 1, 2, 3. Then in every minute,
container 1 will pour its 1/3 of its water into container 1, 2, 3 separately (actually, 1/3 is poured back to
itself, this is allowed by the rule of the game).

输入
Standard input will contain multiple test cases. The first line of the input is a single integer T (1 <= T <=
10) which is the number of test cases. And it will be followed by T consecutive test cases.
Each test case starts with a line containing an integer N , the number of containers. The second line
contains N floating numbers, denoting the initial water in each container. The following N lines describe
the relations that one container(from 1 to N ) will pour water into the others. Each line starts with an
integer K (0 <= K <= N ) followed by K integers. Each integer ([1, N ]) represents a container that should
pour water into by the current container. The last line is an integer M (1<= M <= 1,000,000,000) denoting
the pouring will continue for M minutes.

输出
For each test case, output contains N floating numbers to two decimal places, the amount of water
remaining in each container after the pouring in one line separated by one space. There is no space at
the end of the line.

样例输入
1
2
100.00 100.00
1 2
2 1 2
2
样例输出
75.00 125.00
提示

零基础的同学可以先学习基础,教程见:  C语言教程C++教程编译器教程数据结构教程Python教程单片机教程

视频教学见视频网课

比赛公告

题号:1381,1382,1383,1384,1385,1386,1387,1388,1389,1390

点击上方导航栏的训练,点击题库,寻找题号即可找到对应题目,比赛结束后,请通过训练->题库->寻找对应题目的方式做题

因为不确定因素太多,就不再安排大家轮流讲题了,大家做不出题可以在测试结束后去题库找对应的题目看题解,希望大家自觉练习,认真练习,考核测试会采取不同与现在测试的方式,两个月后综合测试成绩不达标者会退出实验室,希望大家认真对待