当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5117:Fluorescent

题目描述
Matt, a famous adventurer who once defeated a pack of dire wolves alone, found a lost court. Matt finds that there are N fluorescent lights which seem to be the stars from the firmament. What’s more, there are M switches that control these fluorescent lights. Each switch is connected to a group of lights. When Matt touches a switch, all the lights connected to it will change their states (turning the dark on, turning the bright off).

Initially, all the fluorescent lights are dark. For each switch, Matt will touch it with probability 1 .

As a curious gentleman, Matt wants to calculate E[X3], where X represents the number of bright lights at the end, E[X3] represents the expectation of cube of X.
输入解释
The first line contains only one integer T , which indicates the number of test cases.

For each test case, the first line contains N, M (1 ≤ N, M ≤ 50), denoting the number of fluorescent lights (numbered from 1 to N ) and the number of switches (numbered from 1 to M ).

M lines follow. The i-th line begins with an integer Ki (1 ≤ Ki ≤ N ). Ki distinct integers lij(1 ≤ lij ≤ N ) follow, denoting the fluorescent lights that the i-th switch controls.
输出解释
For each test case, output a single line “Case #x: y”, where x is the case number (starting from 1) and y is the answer. To avoid rounding error, the answer you should output is:

E[X3] × 2M mod (109 + 7)
输入样例
2
2 2
1 1
2 1 2
3 1
3 1 2 3
输出样例
Case #1: 10
Case #2: 27

提示
For the first sample, there’re 4 possible situations:
All the switches is off, no light is bright, X^3 = 0.
Only the first switch is on, the first light is bright, X^3 = 1.
Only the second switch is on, all the lights are bright, X^3 = 8.
All the switches is on, the second lights are bright, X^3 = 1.
Therefore, the answer is E[X^3] × 2^2 mod (10^9 + 7) = 10.

For the second sample, there’re 2 possible situations:
The switches is off, no light is bright, X^3 = 0.
The switches is on, all the lights are bright, X^3 = 27.
Therefore, the answer is E[X^3] × 2^1 mod (10^9 + 7) = 27.
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-5117

最后修改于 2020-10-25T23:19:56+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
3000/3000MS(Java/Others) 512000/512000K(Java/Others)