随笔分类 -  暴力

摘要:/*ZOJ Problem Set - 3657The Little Girl who Picks MushroomsTime Limit: 2 Seconds Memory Limit: 32768 KBIt's yet another festival season in Gensokyo. Little girl Alice planned to pick mushrooms in five mountains. She brought five bags with her and used different bags to collect mushrooms from di. 阅读全文
posted @ 2013-08-01 17:44 myth_HG 阅读(288) 评论(0) 推荐(0)
摘要:/*调用算法中函数求写一个排序*/#include #include#include#include#include#include#include#includeusing namespace std;#define maxn 2600000typedef int State[9];State st[maxn],goal;int dist[maxn];const int dx[]= {-1,1,0,0};const int dy[]= {0,0,-1,1};int vis[36288],fact[9];/*void init_lookup_table(){ int i; fact... 阅读全文
posted @ 2013-07-25 20:31 myth_HG 阅读(219) 评论(0) 推荐(0)
摘要:/* ID Codes It is 2084 and the year of Big Brother has finally arrived, albeit a century late. In order to exercise greater control over its citizens and thereby to counter a chronic breakdown in law and order, the Government decides on a radical measure--all citizens are to have a tiny microcompute 阅读全文
posted @ 2013-07-24 09:16 myth_HG 阅读(388) 评论(0) 推荐(0)
摘要:/*困难串(无两个相邻的重复字串)*/#include #include#include#include#include#include#include#includeusing namespace std;#define maxn 1000int cnt,n,L;int S[maxn];int dfs(int cur)//返回0表示已经得到解,无须继续搜索{ int i,ok,j,k,equals; if(cnt++==n)//输出方案 { for(i=0; i<cur; i++) printf("%c",'A'+S[i]); ... 阅读全文
posted @ 2013-07-22 16:25 myth_HG 阅读(436) 评论(0) 推荐(0)
摘要:/*n皇后问题*/#include #include#include#include#include#include#include#includeusing namespace std;#define maxn 1000int n,tot,col[maxn],vis[3][maxn];void search(int cur){ int i,j; if(cur==n) { tot++; printf("----解%d:----\n",tot); for(i=0; i<n; i++) { printf... 阅读全文
posted @ 2013-07-22 10:45 myth_HG 阅读(277) 评论(0) 推荐(0)
摘要:/*子集生成的各种实现*/#include #include#include#include#include#include#include#includeusing namespace std;#define maxn 26000int A[maxn];int B[maxn];int n,sum;void print_subset(int n,int *A, int cur)//用增量法实现子集生成{ int i; for(i=0; i < cur ; i++) { printf("%d ",A[i]);//打印当前集合 if(i==0) ... 阅读全文
posted @ 2013-07-21 18:47 myth_HG 阅读(358) 评论(0) 推荐(0)
摘要:/*枚举生成可重集排列*/#include #include#include#include#include#include#include#includeusing namespace std;#define maxn 2600000int A[maxn];int P[maxn];int sum;void print_p(int n,int *A,int *P,int cur){ int i,j; if(cur==n) { for(i=0; i#include#include#include#include#include#include#includeusi... 阅读全文
posted @ 2013-07-19 17:31 myth_HG 阅读(280) 评论(0) 推荐(0)
摘要:/*枚举生成1~n的排列*/#include #include#include#include#include#include#include#includeusing namespace std;#define maxn 2600000int A[maxn];void print_p(int n,int *A,int cur){ int i,j; if(cur==n) { for(i=0;i<n;i++) printf("%d ",A[i]); printf("\n"); } else { for(i... 阅读全文
posted @ 2013-07-19 16:33 myth_HG 阅读(253) 评论(0) 推荐(0)