上一页 1 2 3 4 5 6 7 8 ··· 28 下一页

2012年8月22日

HDU 2602 Bone Collector (dp问题之01背包)

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=2602思路:dp问题之01背包代码如下:一维的,我习惯的作风。。。 1 #include<stdio.h> 2 #include<stdlib.h> 3 #include<string.h> 4 #define N 1001 5 int dp[N]; 6 int c[N],w[N]; 7 int max(int x,int y) 8 { 9 return x>y?x:y;10 }11 int main()12 {13 int t,n,v,i,j;14 scanf 阅读全文

posted @ 2012-08-22 09:56 mycapple 阅读(369) 评论(0) 推荐(0) 编辑

2012年8月21日

HDU 1421 搬寝室 (dp)

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1421思路:动态规划dp借鉴代码如下: 1 #include<cstring> 2 #include<iostream> 3 #include<algorithm> 4 #define P(x,y) ((x-y)*(x-y)) 5 using namespace std; 6 int a[2010],d[2010][2010]; 7 int main() 8 { 9 int i,j,n,k;10 while(cin>>n>>k){11 for( 阅读全文

posted @ 2012-08-21 20:38 mycapple 阅读(187) 评论(0) 推荐(0) 编辑

POJ 3767 I Wanna Go Home (dijkstra算法)

摘要: 地址:http://poj.org/problem?id=3767题目分析:由于战争,一个商人想从城市1,回到自己的家城市2,其中城市1始终是由领导1,城市2始终由领导2,其中,商人回家的路中只能有一条路上连接由两个领导领导的城市,还有就是给出的路上双向的,也就是如果城市1能到城市2,那么城市2也同样能到城市1,这是关键。由于这个题中从1类城市走到2类城市后就不能再回去,只能穿过一次,所以先存为双向路,后面再根据不同类型的城市,把双向路变为单向路N个城市,城市编号为1,2,3,……NM条路,路为双向路。 提供每条路的长度及端点城市编号,每两个城市之间直接连通的路最多一条。这N个城市分为两个集合 阅读全文

posted @ 2012-08-21 19:25 mycapple 阅读(458) 评论(0) 推荐(0) 编辑

HDU 2544 最短路 (dijkstra算法)

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=2544思路:(dijkstra算法)代码如下: 1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 #define Max 0xfffffff 5 int m[10010][10010],p[10010]; 6 bool vis[10010]; 7 int vexnum,arcnum; 8 void dijstra() 9 {10 int i,j,k,t,min;11 memset(vis,0 阅读全文

posted @ 2012-08-21 16:15 mycapple 阅读(1182) 评论(0) 推荐(1) 编辑

HDU 1142 A Walk Through the Forest (dijkstra算法)

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1142思路1:题目大意是给你一个图。起点为1,终点为2然后点a到点b是合法的判断(Notice 1:)是当b存在一个到终点的距离小于a到终点的最小距离,求从起点到终点的路径数。Notice 1:不合法并非是断路,合法指回家的时候只按dis[b] < dis[a]的路线走、dis[]表示到终点2的最短路径, 满足dis[b] < dis[a], 表示这样a->b的是可选择的。 就是说每次回家时选择从距起点(最短距离)近的点 向 距起点(最短距离)远的点走, 求这样的路线条数。dp[i] 阅读全文

posted @ 2012-08-21 12:28 mycapple 阅读(291) 评论(0) 推荐(0) 编辑

2012年8月20日

棋盘覆盖问题

摘要: 地址:http://acm.hunnu.edu.cn/online/?action=problem&id=10432&type=show题目在线:棋盘覆盖问题Time Limit: 1000ms, Special Time Limit:2500ms, Memory Limit:32768KBTotal submit users: 62, Accepted users: 26Problem 10432 : No special judgementProblem description在一个2k x 2k ( 即:2^k x 2^k )个方格组成的棋盘中,恰有一个方格与其他方格不同 阅读全文

posted @ 2012-08-20 21:07 mycapple 阅读(9113) 评论(1) 推荐(2) 编辑

NK 1437 校长杯

摘要: 地址:http://acm.nankai.edu.cn/p1437.html思路:http://wenku.baidu.com/view/a081ee49e45c3b3567ec8bf4.html 不太懂。。。题目: 1437: 校长杯Time Limit: 1500 ms Memory Limit: 32000 kB Judge type: Multi-cases Special JudgeTotal Submit : 108(51 users)Accepted Submit : 65(45 users)Page View : 3964Font Style: Aa Aa Aa 在南开大学.. 阅读全文

posted @ 2012-08-20 20:27 mycapple 阅读(252) 评论(0) 推荐(0) 编辑

HDU 1372 Knight Moves

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1372思路:求“马”从一点到另一点的最短距离,马走日,BFS即可分析:广度优先搜索题题意如图所示:一个棋子(骑士)可以有八个方向走,广搜确定最小的走的步数。代码如下: 1 #include <iostream> 2 #include <stdio.h> 3 #include <string.h> 4 #include <queue> 5 using namespace std; 6 int c[9][9]; 7 int dir[8][2] = {{-2,- 阅读全文

posted @ 2012-08-20 20:01 mycapple 阅读(506) 评论(0) 推荐(0) 编辑

NYOJ 283 对称排序

摘要: 地址:http://acm.nyist.net/JudgeOnline/problem.php?pid=283题目分析:意思是你已经写好了一个程序,可惜你的程序输出方式老板不喜欢!However, your boss does not like the way the output looks, and instead wants the output to appear more symmetric, with the shorter strings at the top and bottom and the longer strings in the middle.老板希望你能“symme 阅读全文

posted @ 2012-08-20 12:49 mycapple 阅读(637) 评论(0) 推荐(0) 编辑

NYOJ 514 1的个数

摘要: 地址:http://acm.nyist.net/JudgeOnline/problem.php?pid=514思路1:有篇博文写的是统计二进制中1的个数和,这篇是统计区间内十进制的1的个数和。先讨论下1到n间的1的个数和。给你一个数如:384,求1~384的1的个数之和。那么我只需求出1~300中1的个数和+1~80中1的个数和+1~4中1的个数和。1~4的1的个数为1,1~80中1的个数为101(十位数)+8*100(个位数)----十位数有10,11,12,13....19(共10个数--其中11后面的1作为个位数看待),个位数为1,11,21,31...71,共有8个1,同理可得1~30 阅读全文

posted @ 2012-08-20 08:49 mycapple 阅读(558) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 7 8 ··· 28 下一页

导航