uva 10160
											题目大意:有n个点(3<=n<=35),有m条边连接点与点。如果在某个点安装电灯,该点与相连的点都有光亮。写个程序装最小的灯使所有点都有光亮。若干组数据,以n=0 m=0结束。
样例输入
8 12
1 2
1 6
1 8
2 3
2 6
3 4
3 5
4 5
4 7
5 6
6 7
6 8
8 10
1 2
1 3
1 4
1 5
6 2
6 3
6 4
6 5
1 7
7 8
0 0
样例输出
2
2
我的程序不知错哪了
程序代码:
#include<cstdio>
#include<cstring>
#define oo 2000000000
#define min(a,b)((a)<(b)?(a):(b))
int n,m,x,y,ans;
int road[36][36];
bool map[36][36];
void doit(int num,int x,bool a[],int station)
{
     if (!a[x]) return; 
     station++; num++; a[x]=false;
     for (int i=1;i<=road[x][0];i++)
       if (a[road[x][i]])
       {
          num++;
          a[road[x][i]]=false;
       }
     if (num==n) 
     {
        ans=min(ans,station);
        return;
     }
     for (int j=x+1;j<=n;j++)
     doit(num,j,a,station);
}
int main()
{
    bool b[36];
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    while (scanf("%d%d",&n,&m)==2 && (n || m))
    {
          //special
          if (m==0) {printf("%d\n",n); continue;}
          //fill
          memset(road,0,sizeof(road));
          memset(map,false,sizeof(map));
          memset(b,true,sizeof(b));
          ans=oo;
          //read
          for (int i=1;i<=m;i++)
          {
              scanf("%d%d",&x,&y);
              if (x==y) continue;
              map[x][y]=map[y][x]=true;
              road[x][++road[x][0]]=y;
              road[y][++road[y][0]]=x;
          }
          //doit 
          for (int i=1;i<=n;i++) 
          {
              doit(0,i,b,0);
              memset(b,true,sizeof(b));
          }
          //print
          printf("%d\n",ans);
    }
    return 0;
}
										
					
	


											
	    

	