上一页 1 ··· 93 94 95 96 97 98 99 100 101 ··· 121 下一页
摘要: 最近重新学习了一下KMP算法,然后重新做了自己的模板。题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1686 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 #define MAXN 10010 7 #define MAXM 1000010 8 char str1[MAXN]; 9 char str2[MAXM];10 int Next[MAXN];11 12 int len1,len2;13 14 void Get_Next(){15 int j=... 阅读全文
posted @ 2013-05-20 10:57 ihge2k 阅读(250) 评论(0) 推荐(0)
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4308思路:就是一般的广搜,然后要注意的地方就是位置P了,一次把所有的都入队列,然后标志置为true。别的的话就是随便搞搞就行了。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<queue> 5 using namespace std; 6 #define inf 1<<30 7 #define MAXN 5050 8 struct Node{ 阅读全文
posted @ 2013-05-19 19:50 ihge2k 阅读(235) 评论(0) 推荐(0)
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4548思路:打表什么的没有什么技巧性可言,最后二分的时候得小心返回位置!!! 1 #include 2 #include 3 #include 4 using namespace std; 5 bool mark[1000010]; 6 int num[1000010]; 7 int k; 8 9 int Judge(int n){10 int ans=0;11 while(n){12 ans+=n%10;13 n/=10;14 }15 ... 阅读全文
posted @ 2013-05-18 18:56 ihge2k 阅读(601) 评论(0) 推荐(0)
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1983思路:算得上是暴力解放了。。。orz...由于最多封锁4个区域,因此直接dfs枚举,bfs暴搜即可!!!跑了将近4000ms啊... 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<queue> 5 using namespace std; 6 #define MAXN 10 7 struct Node{ 8 int x,y,time; 9 int ke 阅读全文
posted @ 2013-05-18 11:21 ihge2k 阅读(239) 评论(0) 推荐(0)
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2512思路:dp[i][j]表示第i张校园卡放到j本书中(保证每本书中必须至少有一张校园卡)的方案数,于是有dp[i][j]=j*dp[i-1][j]+dp[i-1][j-1](从i-1到i的状态可以在有j本书的情况下选择任意一本书放入校园卡,也可以放入放到新加进来的书中)这样的话最后只要FOR(i,1,n)sum+=dp[n][1]就可以啦(表示n张校园卡可以放入一本书或者2本书...或者n本书的情况总和)。 1 #include<iostream> 2 #include<cst 阅读全文
posted @ 2013-05-18 11:21 ihge2k 阅读(226) 评论(0) 推荐(0)
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1895思路:就是先两两合并,然后排序一下二分就可以了,最后要注意的地方就是二分找到解得时候,还要看一下相邻的数是否与解相等(因为可能有多个这样的数)Ps:郁闷死了,一开始用的是long long ,然后wa到死,结果改成int就过了,而且那个1000000007也没有用,orz... 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define MAXN 333 8 int num[6] 阅读全文
posted @ 2013-05-18 10:01 ihge2k 阅读(214) 评论(0) 推荐(0)
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1044思路:看网上大牛们的做法都是bfs+dfs,弱菜表示不会啊,然后觉得bfs也应该不会超时吧,就搞了一把,orz...890ms险过。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<queue> 5 using namespace std; 6 #define MAXN 52 7 struct Node{ 8 int x,y,time; 9 int va 阅读全文
posted @ 2013-05-17 16:09 ihge2k 阅读(344) 评论(1) 推荐(0)
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1973思路:简单bfs,先打个素数表,然后就是广搜搞一下就ok了。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cmath> 5 #include<queue> 6 #include<string> 7 using namespace std; 8 #define MAXN 10100 9 struct Node{10 string 阅读全文
posted @ 2013-05-16 17:14 ihge2k 阅读(437) 评论(0) 推荐(0)
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1885思路:对于钥匙,才4把,直接状态压缩搞一下就好了,然后就是开个三位数组标记状态了,跟普通bfs没什么区别。 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cmath> 5 #include<queue> 6 using namespace std; 7 #define MAXN 110 8 struct Node{ 9 int x,y,st 阅读全文
posted @ 2013-05-15 22:35 ihge2k 阅读(577) 评论(0) 推荐(0)
摘要: 贴几道bfs题。题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2216思路:用一个四维的数组来保存状态,然后就是一般的bfs了,不过要注意的S,Z的初始位置要置为'.'(这个地方debug了好久,orz...).View Code 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cmath> 5 #include<queue> 6 using namespace std; 7 # 阅读全文
posted @ 2013-05-14 23:51 ihge2k 阅读(274) 评论(0) 推荐(0)
上一页 1 ··· 93 94 95 96 97 98 99 100 101 ··· 121 下一页