标签:des style blog http color java os io strong
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 800 Accepted Submission(s): 410
1 #include<cstring> 2 #include<cstdio> 3 const int maxn=305; 4 int aa[maxn],bb[maxn]; 5 int n,m; 6 int main(){ 7 int test; 8 //freopen("test.in","r",stdin); 9 scanf("%d",&test); 10 while(test--){ 11 scanf("%d%d",&n,&m); 12 for(int i=0;i<m;i++){ 13 scanf("%d%d",aa+i,bb+i); 14 } 15 int ans=m+2; 16 for(int i=0;i<(1<<n);i++) //2^n种情况,对于每一个星球都可以两种情况要么为左,要么为右 17 { 18 int cnt=0; 19 for(int j=0;j<m;j++){ 20 if(((i>>aa[j])%2)==((i>>bb[j])%2)) //属于同一个世界,说明呵呵存在奇数环 21 cnt++; 22 } 23 if(ans>cnt)ans=cnt; 24 } 25 printf("%d\n",ans); 26 } 27 return 0; 28 }
标签:des style blog http color java os io strong
原文地址:http://www.cnblogs.com/gongxijun/p/3930228.html