Instability
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 232 Accepted Submission(s): 92
Problem Description
Long long ago, there was a prosperous kingdom which consisted of n cities and every two cites were connected by an undirected road.
However, one day a big monster attacked the kingdom and some roads were destroyed. In order to evaluate the influence brought by the catastrophe, the king wanted to know the instability of his kingdom. Instability is defined as the number of the unstable subset of {1, 2, ⋯ ,n}.
A set S is unstable if and only if there exists a set A such that A⊆S(|A|≥3 ) and A is a clique or an independent set, namely that cites in A are pairwise connected directly or they are pairwise disconnected.
Archaeologist has already restored themroads that were not destroyed by the monster. And they want you to figure out the instability.
Since the answer may be tremendously huge, you are only required to write a program that prints the answer modulo 1000000007.
However, one day a big monster attacked the kingdom and some roads were destroyed. In order to evaluate the influence brought by the catastrophe, the king wanted to know the instability of his kingdom. Instability is defined as the number of the unstable subset of {1, 2, ⋯ ,n}.
A set S is unstable if and only if there exists a set A such that A⊆S(|A|≥3 ) and A is a clique or an independent set, namely that cites in A are pairwise connected directly or they are pairwise disconnected.
Archaeologist has already restored themroads that were not destroyed by the monster. And they want you to figure out the instability.
Since the answer may be tremendously huge, you are only required to write a program that prints the answer modulo 1000000007.
Input
The first line contains only one integer T, which indicates the number of test cases.
For each test case, the first line contains two integers n ( 3≤n≤50 ) and m ( 1≤m≤n(n−1)/2 ), indicating the number of cities and the number of roads.
Then the following are m lines, each of which contains two integers x and y, indicating there is a road between the city x and the city y.
It is guarenteed that there does not exist a road connecting the same city and there does not exist two same roads.
For each test case, the first line contains two integers n ( 3≤n≤50 ) and m ( 1≤m≤n(n−1)/2 ), indicating the number of cities and the number of roads.
Then the following are m lines, each of which contains two integers x and y, indicating there is a road between the city x and the city y.
It is guarenteed that there does not exist a road connecting the same city and there does not exist two same roads.
Output
For each test case, print a line “Case #x: y”, where x is the case number (starting from 1) and y is an integer indicating the instability modulo 1000000007.
Sample Input
2 4 3 1 2 2 3 1 3 3 0
Sample Output
Case #1: 2 Case #2: 1Hint• In the first example, {1,2,3} and {1,2,3,4} , containing the subset {1,2,3} which is connected directly, are considered unstable. • In the second example, {1,2,3} is considered unstable because they are not pairwise connected directly.
Source
http://acm.split.hdu.edu.cn/showproblem.php?pid=5917
一个集合里面只要有>=3个点两两相连或两两都不相连 就认为这个集合是稳定的
求这样集合的总和
里面有个重要的定理 ramsey定理(百度吧)
世界上任意的6个人中 总有三个相互认识或都不认识
所以此题只有>=6个点都满足
变成c(n,0)+c(n,1)+c(n,2)+..........+c(n,6)+c(n,7)+......c(n,n);
这个式子的总和就等于2^n(高中知识了)
大于5的都成立 所以只要判断3到5个点的
减去就就行了
代码在下面的链接
http://blog.csdn.net/u014325920/article/details/52750175