2011年3月8日

poj 1852

摘要: 简单模拟,把所有蚂蚁看成一样的。#include<iostream>#include<fstream>using namespace std;int n,m;int main(){ int i,j,k; int K,ans,ans1,s,t;// ifstream cin("in.txt"); cin>>K; while(K--) { ans=0; ans1=0; cin>>n; cin>>m; for(i=1;i<=m;i++) { cin>>s; t=n-s; if(s>t) { k=t 阅读全文

posted @ 2011-03-08 19:31 宇宙吾心 阅读(307) 评论(0) 推荐(0)

poj 3150

摘要: 矩阵乘法,运用循环矩阵性质。代码:#include<iostream>#include<fstream>#include<cmath>using namespace std;long long map[501][501],map1[501][501],map2[501][501];long long m,d;long long k;long long a[501],b[501];int n;void solve(long long k){ long long i,j; if(k==1) { for(i=1;i<=n;i++) for(j=1;j< 阅读全文

posted @ 2011-03-08 19:02 宇宙吾心 阅读(413) 评论(0) 推荐(0)

poj 2118

摘要: 矩阵乘法。(a[n],a[n+1],a[n+2])=(a[0],a[1],a[2])*A^n.代码:#include<iostream>#include<fstream>using namespace std;int a[110];int map[110][110],map1[110][110],map2[110][110];int n;long long m;void solve(long long m){ int i,j,k; if(m==1) for(i=1;i<=n;i++) for(j=1;j<=n;j++) map1[i][j]=map[i][j 阅读全文

posted @ 2011-03-08 16:56 宇宙吾心 阅读(215) 评论(0) 推荐(0)

poj 1625

摘要: ac自动机+高精+dp高精输出适用了cout.wide cout.fill('0');代码:#include<iostream>#include<fstream>using namespace std;struct e{ int p[51]; int end;}trie[501];int n,m,K;int hash[600];int state=1;int f[501];void build(char c[]){ int i,j=0,k; for(i=1;;) { if(trie[i].p[hash[c[j]]]==0) trie[i].p[hash[ 阅读全文

posted @ 2011-03-08 15:30 宇宙吾心 阅读(840) 评论(0) 推荐(0)

poj 1177

摘要: 线段树,详见陈宏的论文。简单讲就是每两次覆盖之间的差值的总和。代码:#include<iostream>#include<fstream>#include<cmath>using namespace std;struct e{ int l,r,conut,size;}tree[5000*8];int a[20001];int b[20001];int a1[10001];int b1[10001];int n;struct xxx{ int s,t,f,x;}xx[10001];struct yyy{ int s,t,f,y;}yy[10001];void 阅读全文

posted @ 2011-03-08 10:45 宇宙吾心 阅读(914) 评论(0) 推荐(0)

导航