摘要: 模拟栈View Code const int MM = 555555;#define debug puts("wrong")int to[MM], cnt, ans;char str[MM], ch[MM];char st[MM]; int top;void solve() { int i,j,k, n=strlen(str+1), m=strlen(ch+1); ans=0; top=0; str[0]='#'; for(i=1;i<=m;i++) { if(ch[i]==str[n]) { for(j=n-1;j>0;j--) i... 阅读全文
posted @ 2013-04-18 22:04 zhang1107 阅读(151) 评论(0) 推荐(0) 编辑
摘要: View Code /*================================*\| 筛素数 [1..n]\*================================*/bool isp[MM]; int prm[MM];int get_prime(int n) { int i,j,k=0; int s, e=(int)(sqrt(0.0+n)+1); for(i=0;i<=n;i++) isp[i]=true; prm[k++]=2; isp[0]=isp[1]=false; for(i=4;i<n;i+=2) isp[i]=false; ... 阅读全文
posted @ 2013-04-18 19:34 zhang1107 阅读(129) 评论(0) 推荐(0) 编辑
摘要: //组合数 com(n,r)View Code /*==========================*\| 组合数 com(n,r)\*==========================*/const int maxn = 100; //元素个数int com[maxn][maxn]; //注意 long longvoid get_com() { int i,j,k; for(i=0;i<maxn;i++) { com[i][0]=1; for(j=1;j<=i;j++) com[i][j]=com[i-1][j-1]+com[i-1][j]; ... 阅读全文
posted @ 2013-04-18 11:31 zhang1107 阅读(125) 评论(0) 推荐(0) 编辑
摘要: http://codeforces.com/problemset/problem/51/B利用stack类似与括号匹配,每个<table>ROWS</table> 划分一个模块,一个<td>TABLE</td>记录多少个CELL, stack中存的是模块的序号。View Code const int MM = 511111;const double esp=1e-8;const double lep=0.0000001;#define maxint 0x3f3f3f3ftypedef __int64 int64;#define debug put 阅读全文
posted @ 2013-04-18 10:50 zhang1107 阅读(200) 评论(0) 推荐(0) 编辑
摘要: http://codeforces.com/problemset/problem/51/C两次二分+贪心, 被卡精度卡了好久,发现整数点的话,结果不是整数就是 xxx.5的直接整数解决,就不会有精度问题啦。以后注意利用题目条件, double代码留作纪念。View Code const int MM = 511111;const double esp=1e-8;const double lep=0.0000001;#define debug puts("wrong")#define clr(a) memset(a,0,sizeof(a))int N,M,mm;int x[M 阅读全文
posted @ 2013-04-18 10:35 zhang1107 阅读(197) 评论(0) 推荐(0) 编辑