本题来源于:2014 年 ACM/ICPC 亚洲区北京站
有 个灯, 个开关,每个开关能控制一些灯的状态,即关闭的打开,打开的关闭。一开始灯全部是关闭的。现在有个人去操作这些开关,显然会有 次组合。现在问这个人操作完这些开关后,亮着的灯的期望 。但是题目要求输出的是 。
The first line contains only one integer , which indicates the number of test cases.
For each test case, the first line contains (), denoting the number of fluorescent lights (numbered from to ) and the number of switches (numbered from to ).
lines follow. The -th line begins with an integer (). distinct integers () follow, denoting the fluorescent lights that the -th switch controls.
For each test case, output a single line Case
, where is the case number (starting from ) and is the answer. To avoid rounding error, the answer you should output is:
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 possible situations:
All the switches is off, no light is bright, .
Only the first switch is on, the first light is bright, .
Only the second switch is on, all the lights are bright, .
All the switches is on, the second lights are bright, .
Therefore, the answer is .
For the second sample, there’re possible situations:
The switches is off, no light is bright, .
The switches is on, all the lights are bright, .
Therefore, the answer is .
Matt, a famous adventurer who once defeated a pack of dire wolves alone, found a lost court. Matt finds that there are fluorescent lights which seem to be the stars from the firmament. What’s more, there are 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 .
As a curious gentleman, Matt wants to calculate , where X represents the number of bright lights at the end, represents the expectation of cube of .
The first line contains only one integer , which indicates the number of test cases.
For each test case, the first line contains (), denoting the number of fluorescent lights (numbered from to ) and the number of switches (numbered from to ).
lines follow. The -th line begins with an integer (). distinct integers () follow, denoting the fluorescent lights that the -th switch controls.
For each test case, output a single line Case
, where is the case number (starting from ) and is the answer. To avoid rounding error, the answer you should output is:
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 possible situations:
All the switches is off, no light is bright, .
Only the first switch is on, the first light is bright, .
Only the second switch is on, all the lights are bright, .
All the switches is on, the second lights are bright, .
Therefore, the answer is .
For the second sample, there’re possible situations:
The switches is off, no light is bright, .
The switches is on, all the lights are bright, .
Therefore, the answer is .