摘要: 计算一个十进制数的位数 (int)log10((double)i) + 1#include #include unsigned int a[32000], s[32000];void table(){ int i; a[1] = 1; s[1] = 1; for(i = 2; i < 31270; i++) { a[i] = a[i-1] + (int)log10((double)i) + 1; //第i组数字的个数,120算是三个 s[i] = s[i-1] + a[i]; /... 阅读全文
posted @ 2014-01-17 11:26 单调的幸福 阅读(219) 评论(0) 推荐(0) 编辑
摘要: Map是标准关联式容器(associativecontainer)之一,一个map是一个键值对序列,即(key ,value)对,Key - value的对应。key 和 value可以是任意你需要的类型。。它提供基于key的快速检索能力,在一个map中key值是唯一的。map提供双向迭代器,即有从前往后的(iterator),也有从后往前的(reverse_iterator)。map要求能对key进行#include#includeusing namespace std;string s1,s2,s12,s;int t;void shuffle( ){ int i; s.clea... 阅读全文
posted @ 2014-01-16 16:54 单调的幸福 阅读(182) 评论(0) 推荐(0) 编辑
摘要: #include #include char dic[10005][20];int t;int del(char a[],char b[]){ int i; for(i=0;a[i];i++) if(a[i]!=b[i]) break; if(!strcmp(a+i+1,b+i)) return 1; return 0;}int rep(char a[],char b[]){ int i; for(i=0;a[i];i++) if(a[i]!=b[i]) break; if(!st... 阅读全文
posted @ 2014-01-15 18:56 单调的幸福 阅读(141) 评论(0) 推荐(0) 编辑
摘要: #include #include using namespace std;structnode{ int x, y;} p[1005];bool Greater(const structnode &a, const structnode &b){ if (a.x == b.x) return a.y =p[j].y) //重复的正方形不要 { p1.x = p[i].x + p[j].y - p[i].y; p1.y = p[i].y + p[i].x - p[j].x; ... 阅读全文
posted @ 2014-01-15 17:58 单调的幸福 阅读(132) 评论(0) 推荐(0) 编辑
摘要: #include #define N 500005using namespace std;int a[N],a1[N];__int64 time; //范围为 -2^63 (-9,223,372,036,854,775,808) 到 2^63-1 (9,223,372,036,854,775,807),存储空间占 8 字节。void Merge (int s,int m,int t){ int i=s,j=m+1,k=0; while (i<=m && j<=t) { if(a[i]<=a[j]) a1[k++]=a[i++]; ... 阅读全文
posted @ 2014-01-15 12:56 单调的幸福 阅读(194) 评论(0) 推荐(0) 编辑
摘要: #include #include #define N 100005char str1[N],str2[N];int main(){ int i,j,len1,len2; while(scanf("%s %s",str1,str2)!=EOF) { j=0; len1=strlen(str1); len2=strlen(str2); for(i=0;i<len2;i++) if(str1[j]==str2[i]) j++; if(j==len1) ... 阅读全文
posted @ 2014-01-14 11:23 单调的幸福 阅读(149) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #define N 105#define INF 1000000000using namespace std;structnode{ int x,y;};node dir[4]={{-1,0},{1,0},{0,1},{0,-1}} ;int p[N][N],maps[N][N],visit[N][N],value[N][N],n,m,num;void bfs(int x,int y) { queueQ; node t,u,v; int xi,yi,i; t.x=x; t.y=y; me... 阅读全文
posted @ 2014-01-13 21:55 单调的幸福 阅读(146) 评论(0) 推荐(0) 编辑
摘要: #include #include int map[28][28],num,n;char output[28];int Floyd(){ int i,k,j; for(i=1;i1) return 0; for(k=1;k<=n;k++) if(map[ind][k]) degree[k]--; } output[num]='\0'; return 2;}int main(){ int m,flag,i,pos; char str[4]; while( scanf("%d%d",&n,&m)!=EOF && ( n || 阅读全文
posted @ 2014-01-13 13:18 单调的幸福 阅读(204) 评论(0) 推荐(0) 编辑
摘要: 二分图的最小覆盖=最大匹配这是为什么呢?让我们来分析一下,这里有一个很好的模拟过程:将右边未匹配上的点依次加标记,然后标记左边与右边标记的相连的点,左边的点一定是最大匹配上的点,不然找到的一定不是最大匹配,标记最大匹配且左边已经标记了的点。最后取左边标记了的点和右边未标记的点就组成了最小覆盖。现在最大匹配的点一定都覆盖了,左边是最大匹配,右边不是的边也覆盖了,右边是最大匹配,左边不是这种情况也覆盖了。所有情况都覆盖了,而左边标记了的点由最大匹配对应的右边的点与右边未标记的(为标记一定是最大匹配上的)加起来就是最大匹配数。图的独立集:寻找一个点集,其中任意两点在图中无对应边。二分图的最大独立集= 阅读全文
posted @ 2013-12-25 15:38 单调的幸福 阅读(209) 评论(0) 推荐(0) 编辑
摘要: #include #include #include using namespace std;int parent[5000],n,ans;structnode{ int from,to,weight;}grid[5000];bool com_greater(node vex1 ,node vex2){ return vex1.weight-1) t=parent[t]; return t;}void kruscal(int k){ ans=0; int i,vex1,vex2,num; for (i=1;ii) ... 阅读全文
posted @ 2013-12-22 17:42 单调的幸福 阅读(136) 评论(0) 推荐(0) 编辑