# 求教大身，用C语言的算法实现mod 109+7算法问题

Problem Description
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.

Input
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.

Output
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)

Sample Input
2
2 2
1 1
2 1 2
3 1
3 1 2 3

Sample Output
Case #1: 10
Case #2: 27

• 写回答

#### 1条回答默认 最新

• threenewbee 2019-08-12 23:49
关注
本回答被题主选为最佳回答 , 对您是否有帮助呢?
评论

#### 悬赏问题

• ¥15 Google Chrome 所有页面崩溃，三种解决方案都没有解决，我崩溃了
• ¥18 如何用c++编写数学规律题
• ¥20 使用uni-app发起网络请求，获取重定向302返回的cookie
• ¥20 手机外部浏览器拉起微信小程序支付 （相关搜索：微信小程序）
• ¥20 怎样通过一个网址找到其他同样模版的网址
• ¥30 XIAO esp32c3 读取FDC2214的数据
• ¥15 在工控机（Ubuntu系统）上外接USB蓝牙硬件进行蓝牙通信
• ¥15 关于PROCEDURE和FUNCTION的问题
• ¥100 webapi的部署(标签-服务器)
• ¥20 怎么加快手机软件内部计时的时间(关键词-日期时间)