2011年4月2日

UVa193Graph Coloring

摘要: DFS 题意:相邻的节点不能都涂成黑色,问是黑色节点最多的方案(只能选择黑和白)#include<iostream>#include<cstring>#include<stdio.h>using namespace std;int G[101][101],black[101],ANS[101];int n,m,ans;void DFS(int cur,int w)//cur当前要处理的节点,当前已有白色节点个数{ if(w>=n-ans)return;//白色节点多于最优情况下白色节点时 if(cur==n+1) { ans=n-w; for(int 阅读全文
posted @ 2011-04-02 16:51 4.5.6 阅读(183) 评论(0) 推荐(0) 编辑

UVa729 The Hamming Distance Problem

摘要: 求输出所有 含h个1的且长度为n的01串可重集全排列 集合为{1,0} #include<iostream>#include<stdio.h>using namespace std;int cas,n,h;int tmp[17];void DFS(int cur,int num){ if(num>h)return; if(cur==n) { if(num==h) { for(int i=0;i<n;i++) printf("%d",tmp[i]); printf("\n"); } return; } for(int i 阅读全文
posted @ 2011-04-02 14:27 4.5.6 阅读(247) 评论(0) 推荐(0) 编辑