上一页 1 2 3 4 5 6 7 8 ··· 16 下一页
摘要: /* 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 阅读(373) 评论(0) 推荐(0) 编辑
摘要: /*二分查找(范围统计)*/#include #include#include#include#include#include#include#includeusing namespace std;#define maxn 1000int A[maxn];int lower_bound1(int *A,int x,int y,int v)//二分查找求下界{ int m; while(x=v)//看区别 y=m; else x=m+1; } return x;}int upper_bound1(int *A,in... 阅读全文
posted @ 2013-07-23 17:34 myth_HG 阅读(346) 评论(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 阅读(427) 评论(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 阅读(263) 评论(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 阅读(350) 评论(0) 推荐(0) 编辑
摘要: /*经典移动小球*/#include #include#include#include#include#include#include#includeusing namespace std;#define maxn 26000int left1[maxn],right1[maxn];void link(int x,int y){ right1[x]=y; left1[y]=x;}int main(){ int i,n,casen,x,y,k; char type[2]; while(~scanf("%d%d",&n,&casen)) { for... 阅读全文
posted @ 2013-07-20 20:31 myth_HG 阅读(241) 评论(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 阅读(275) 评论(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 阅读(241) 评论(0) 推荐(0) 编辑
摘要: #include #include#include#include#include#include#include#includeusing namespace std;#define LL long longconst int MAXN = 1000+10;int n,target[MAXN];int main(){ while(~scanf("%d",&n)) { stack s; int A=1,B=1,i; for(i =1 ;i<=n;i++) scanf("%d",&target[i]); i... 阅读全文
posted @ 2013-07-19 15:27 myth_HG 阅读(274) 评论(0) 推荐(0) 编辑
摘要: /*A Simple Problem with IntegersTime Limit: 5000MS Memory Limit: 131072KTotal Submissions: 44944 Accepted: 13169Case Time Limit: 2000MSDescriptionYou have N integers, A1, A2, ... , AN. You need to deal with two kinds of operations. One type of operation is to add some given number to e... 阅读全文
posted @ 2013-07-18 19:42 myth_HG 阅读(291) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 16 下一页