上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 61 下一页
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4708思路:由于N不大,并且我们可以发现通过旋转得到的4个对角线的点的位置关系,以及所要旋转的最小步数,然后把所有的符合条件的都加入数组中,最后排序即得。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 struct Node{ 8 int sum,step; 9 }node[11][11],ans[11][11];10 11 int n,p,k;12 int map[11][11];13 14 ... 阅读全文
posted @ 2013-09-08 19:56 ihge2k 阅读(396) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4715思路:先打个素数表,然后判断一下就可以了。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 bool isprime[7000002]; 9 int num[7000000];10 11 int main()12 {13 int k=0;14 memset(isprime,true,sizeof(isprime));15 isprime[0]=ispri... 阅读全文
posted @ 2013-09-08 19:50 ihge2k 阅读(433) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://code.hdu.edu.cn/showproblem.php?pid=2412思路:这篇文章讲的很清楚:http://wenku.baidu.com/view/84164e1a227916888486d7d6.html。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 using namespace std; 9 10 int dp[222][2];11 int flag[222][2];12 int n;13 vector >G;14 15 void 阅读全文
posted @ 2013-09-08 10:54 ihge2k 阅读(294) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1011思路:dp[i][j]表示以i为根的子树派遣j个士兵占领的最大价值。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define MAXN 111 8 9 10 int dp[MAXN][MAXN];11 int num[MAXN],val[MAXN];12 int n,m;13 bool mark[MAXN];14 vector >G;15 16 void dfs(int 阅读全文
posted @ 2013-09-08 00:13 ihge2k 阅读(175) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3667思路:由于花费的计算方法是a*x*x,因此必须拆边,使得最小费用流模板可用,即变成a*x的形式。具体的拆边方法为:第i次取这条路时费用为(2*i-1)*a (i 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define MAXN 222 8 #define MAXM 22222222 9 #define inf 1que; 42 que.push(vs); 43 wh... 阅读全文
posted @ 2013-09-07 12:34 ihge2k 阅读(191) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3599思路:首先spfa求一下最短路,然后对于满足最短路上的边(dist[v]==dist[u]+w)加入到新图中来,边容量为1,最后求出的最大流就是没有相交的边的最短路径条数。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 using namespace std; 8 #define MAXN 4444 9 #define inf 1 >G; 20 void spfa() 21 { 22 ... 阅读全文
posted @ 2013-09-07 12:27 ihge2k 阅读(532) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=2686思路:典型的状压dp题,dp[s][v]表示到达剩下的车票集合为S并且现在在城市v的状态所需要的最小的花费。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 #define inf 1=0;state--){33 ans=min(ans,dp[state][b-1]);34 for(int u=0;u>i)&1){37 for(int v=0... 阅读全文
posted @ 2013-09-06 20:40 ihge2k 阅读(224) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3085思路:双向广搜,每次从M出发,搜三步,从G出发,搜一步,然后就是判断是否走到对方已经走过的格子,至于魔王的判断,可以用曼哈顿距离。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define MAXN 1000 8 9 struct Node{10 int x,y;11 Node(){}12 Node(int xx,int yy):x(xx),y(yy)... 阅读全文
posted @ 2013-09-06 09:30 ihge2k 阅读(550) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2437思路:只需用一个二维数组记录到达某点时路径长度mod k的最短路径长度,如果余数相同,就更新最小值。dfs暴搜即可。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 #define MAXN 1111 8 #define inf 1 >G;20 21 void dfs(int u,int len)22 {23 if(len%k==0&&num[u]==' 阅读全文
posted @ 2013-09-05 20:18 ihge2k 阅读(227) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2821思路:一开始的时候没注意到,必须从map[i][j]==0的位置开始,然后就是dfs了,回溯的时候稍微注意一下就可以了。 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 int n,m,cnt; 9 char str[33];10 int map[33][33];11 int dir[4][2]={{-1,0},{1,0},{0,-1},{0,1}};12 char Dir[7. 阅读全文
posted @ 2013-09-04 12:51 ihge2k 阅读(222) 评论(0) 推荐(1) 编辑
上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 61 下一页