The managers of a chemical plant, which is notorious for its high pollution, plan to adopt a newly developed device in order to reduce the amount of contaminants emitted. However, engineers in the plant are against this plan, as they doubt the usefulness of the device. As engineers only believe in experimental results, managers decide to hire programmers to make a numerical experiment to convince the engineers.
The new pollution-reducing device consists of several tanks with pipes connecting the tanks. You may assume there is at most one pipe between two tanks. Two tanks are called adjacent if a pipe connects them. When operating, the contaminant circulates in the device among these tanks.
As shown in the Figure-1, the contaminant in one tank in time t, will equally distribute into all adjacent tanks in the time t+1. In other words, if we use Xit to denote the amount of contaminant in tank i at time t, we can use the following formula:
where Iij=1 if tank i and tank j are adjacent, otherwise Iij=0, and where dj is the number of tanks adjacent to tank j. If no tank is adjacent to tank i, we have Xit+1=Xit.
The managers, as well as the engineers, want to know that given the initial amount of contaminant in each tank, how the contaminant will be distributed in all the tanks after a long period of time in circulation. Namely, given Xi0 for all i, what are Xit when the difference between Xit and Xit+1 is so small that it can be ignored. You may assume that this condition will ALWAYS be attained from an initial case in this problem.
The first line of the input contains one integer T (1 <= T <= 10), the number of test cases. T cases then follow. For each test case, the first line consists of two integers: N and M where(1 <= N <= 100, 0 <= M <= N*(N-1)/2), is the number of tanks and pipes. The following N lines give the initial amount of contaminant for each tank, which are nonnegative real numbers and no larger than 100. Then the next M lines give the tanks that each pipe connects, as "A B" (1 <= A, B <= N, A != B) denotes there is a pipe between tank A and tank B.
For each test case, output the final amount of contaminant Xit+1 (one per line), followed by a blank line. The number should be rounded to three digits after the decimal point.
- 学院 Python数据挖掘简易入门
- 学院 HoloLens2开发入门教程
- 学院 2019 Python开发者日-培训
- 博客 Only老K说-爬取妹子图片（简单入门）
- 下载 2020_五一数学建模_C题_整理后的数据.zip
- 学院 R语言入门基础
- 下载 人才招聘系统PHP+MySQL源码
- 博客 Java基础知识面试题（2020最新版）
- 博客 python可视化分析（matplotlib、seaborn、ggplot2）
- 学院 Vue.js 2.0之全家桶系列视频课程
- 学院 初级玩转Linux+Ubuntu(嵌入式开发基础课程)
- 博客 【大总结2】大学两年，写了这篇几十万字的干货总结
- 下载 lena全身原图(非256*256版本,而是全身原图)
- 博客 【项目实战】 图书信息管理系统（Maven，mybatis）（第一个自己独立完成的项目）
- 下载 图书管理系统（Java + Mysql）我的第一个完全自己做的实训项目
- 学院 Python入门视频精讲
- 博客 20行代码教你用python给证件照换底色
- 下载 2018年全国大学生计算机技能应用大赛决赛 大题
- 学院 MySQL数据库从入门到实战应用
- 博客 我以为我对Mysql事务很熟，直到我遇到了阿里面试官
- 下载 Eclipse archetype-catalog.xml
- 学院 使用TensorFlow+keras快速构建图像分类模型
- 博客 Python代码实现飞机大战
- 博客 最近面试Java后端开发的感受：如果就以平时项目经验来面试，通过估计很难，不信你来看看
- 学院 三个项目玩转深度学习（附1G源码）
- 学院 微信小程序开发实战之番茄时钟开发