2012年8月17日
摘要: 由于数据比较弱,所以没用欧拉函数直接枚举也可以过。思路:n为1或者n为2的倍数时一定不存在,为奇数时一定存在。 (ab) % n = (a%n * b%n) % n;CODE:#include<stdio.h>#include<stdlib.h>#include<string.h>usingnamespacestd;intmain(){intn;while(~scanf("%d",&n)){inti;if(n==1||n%2==0){printf("2^?mod%d=1\n",n);continue;}long 阅读全文
posted @ 2012-08-17 09:58 有间博客 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 简单的最小生成树问题,关键在于建图的正确性。CODE:#include<stdio.h>#include<stdlib.h>#include<string.h>#include<algorithm>usingnamespacestd;constintSIZE=110;structnode{intu,v,w;}edge[SIZE*SIZE];intp[SIZE];intfind(intx){returnp[x]==x?x:p[x]=find(p[x]);}intcmp(constnodea,constnodeb){returna.w<=b.w 阅读全文
posted @ 2012-08-17 08:59 有间博客 阅读(132) 评论(0) 推荐(0) 编辑