编程介的小学生 2018-12-30 21:28 采纳率: 20.5%
浏览 315
已采纳

用C语言计算Rainbow Island,计算结果是6fe数字用decimal

Problem Description
Recently, a new emerging game has become popular in Hogwarts.

The goal of the game is to connect all islands in the ground with rainbows. At the beginning, n islands are isolated and the player arrive at the first island. There is a red magic set and a blue magic set on each island. Once the players of the game arrive at one of the islands, they will follow the sequence, which is firstly entering the red magic set, then the blue one. When a player enters the red magic set, he/she has the possibility of p to gain a rainbow, thereby two random island of all will be connected by the rainbow(including which two have been connected). When a player enters the blue magic set, he/she will be sent to one of the s islands with same possibility. One unit of total magic volume will be expended when the player uses the blue magic. At the end of the game, the winner is the one who consumes the least of total magic volume.

However, the brilliant Hermione despises the game, she wants to know the expected magic volume to be taken away the goal of the game was achieved.

Input
There are multiply test cases.

The first line contains an integer T(T<=100), indicates the number of cases.
For each case the first line contains an integer n, indicates the number of the islands. (1<=n<=20)

Then there will be n numbers, pi indicates the possibility to gain a rainbow for the i-th island. (0<pi<1)

The next n lines, each line firstly contains an integer s, then followed by s integers, indicates the number of which the i-th island can arrive at. (1 <= s <= n)

Output
For each test case, you should output “Case #K: “ first, where K indicates the case number and counts from 1. Then output the answer. Round the answer to the sixth digit after the decimal point.

Sample Input
2
3
0.123 0.984 0.63
2 1 2
2 2 3
2 1 3
2
0.75 0.34
2 1 2
2 1 2

Sample Output
Case #1: 4.931167
Case #2: 1.458716

  • 写回答

1条回答 默认 最新

  • threenewbee 2019-09-22 10:26
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?