- 博客(12)
- 资源 (1)
- 收藏
- 关注
原创 poj 3286 How many 0's?
统计每一位上的零的个数#include #include using namespace std;long long cal(long long n){ n++; long long ans=n/10+(n%10>0); long long tmp=100; while(n/tmp) { long long txt=n-tmp;
2013-06-27 17:00:46 674
原创 hdu 4057 Rescue the Rabbit
ac自动机的状压dpdp[i][j][k]表示长度为i,包含字符串的状态为j,自动机的状态为k是否可行。#include #include #include #include using namespace std;const int root=0,N=4;int n,m;bool dp[2][1111][1111];int c[1111][10],a[111];int
2013-06-26 22:54:02 748
原创 poj 3691
ac自动机+dp 自动机上的节点来作为状态dp[i][j]表示长度为i状态为j至少需要转换多少个字符#include #include #include #include using namespace std;const int root=0,N=4;char a[1111];int dp[1111][1111],c[1111][10];struct{ in
2013-06-26 12:03:42 912
原创 1625 Censored! ac自动机+dp+高精度
ac自动机+dp+高精度ac自动机的节点作为状态,dp[i][j]表示长度为i状态为j的种类数。转移时注意已经是串的节点不能转移并且不能被转移即可。需要注意的一点是输入的字符的ascll码有负数。#include #include #include #include using namespace std;const int N=500;char use[501];i
2013-06-25 11:11:23 728
原创 poj 2778 DNA Sequence
ac自动机处理字符串,dp计算答案,用矩阵来加速#include #include #include #include using namespace std;const long long mod=100000;struct{ int next[30],tmp,fail,lon;}trie[111];int lon;int m,n;struct matrix{
2013-06-24 00:10:45 1267
原创 2013 acm 东北四省赛 总结
热身赛就不多说了,不得不提的是随机选择一个数字的那个题目,全场只有两个队伍在0分钟1A,居然都是我们学校的。。。 正赛非常狗血的居然是8.30开始,一开场yikou先撸A题,我则从倒数第二题开始看起。yikou贡献了wa之后发现此题答案会非常巨大,需要高精度。。。随后我发现了K题大水,果断敲之,wa,觉得可能是空格问题,改之,再wa,怒开十倍数组,ac。数据范围给错了,卡了我半个小时。
2013-06-13 23:03:32 2158
原创 poj 1961 Period
#include #include #include using namespace std;const int maxn=1000001;char a[maxn];int next[maxn],count[maxn];int main(){ int n; int time=0; while(scanf("%d",&n),n) { s
2013-06-06 14:11:49 644
原创 poj 2185 Milking Grid
求最小重复矩阵。 首先得证明一个结论,最小重复矩阵一定是靠着左上角的。这个可以利用黏贴技术证明。如果有一个不靠左上角的重复矩阵,必然可以通过黏贴得到一个大小相同的靠左上角的矩阵,这个自己画画就明白了。 第二个就是s=len-next[len]等于一个字符串的最小循环节。至于它是循环节利用画图可以看出来。 至于是最小的可以这么考虑,如果存在更小的
2013-06-06 13:57:34 694
原创 poj 2752 Seek the Name, Seek the Fame
#include #include #include using namespace std;const int maxn=1e6+9;int next[maxn],ans[maxn];char a[maxn];int main(){ while(scanf("%s",a+1)!=EOF) { next[1]=0; int n=str
2013-06-06 01:40:12 891
原创 poj 2406 kmp
#include #include #include using namespace std;const int maxn=1e6+9;int next[maxn];char a[maxn];int main(){ while(1) { memset(a,0,sizeof(a)); scanf("%s",a+1); i
2013-06-06 01:22:34 820
原创 poj 3461 kmp
#include #include #include using namespace std;const int maxn=1e6+9;int next[maxn];char a[maxn],b[maxn];int main(){// freopen("in.txt","r",stdin); int tcase; scanf("%d",&tcase);
2013-06-06 01:11:11 905
原创 poj 2987 Firing 最大权闭合图 网络流
最大权闭合的求法参看黑书#include #include #include using namespace std;const int maxn=5e3+9,maxm=6e4+9;const long long inf=(long long)1<<50;int level[maxn],head[maxn],que[maxn];int lon;struct{ int
2013-06-03 13:32:36 896
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人