自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(53)
  • 资源 (3)
  • 收藏
  • 关注

原创 POJ 3007 Organize Your Train part II map+string

<br />map+string<br /><br /> <br />/*Organize Your Train part IITime Limit: 1000MS Memory Limit: 65536K Total Submissions: 4370 Accepted: 1224 DescriptionRJ Freight, a Japanese railroad company for freight operations has recently constructed

2011-03-12 22:46:00 819

原创 Sukodu 数独游戏小软件及源代码

自己写的一个数独游戏小软件。点击“新游戏”生成一个新游戏,如图1,玩家填入剩余空格,软件有提示功能,如果输入错误,方格背景变为红色,正确则变为绿色。点击“显示答案”则给出当前情况的答案,如图2.点击“手动输入”,然后再输入他处看到的题目,然后点击“显示答案”则可以解答,如图3.图4.。 下载地址:待定。                                       图1                                       图2                      

2011-03-09 19:15:00 1326 1

原创 POJ 1050 To the Max

<br />一维最大子段和的扩展,枚举多行合成一行的情况,然后使用一维最大子段和的方法计算。<br /><br />/*To the MaxTime Limit: 1000MS Memory Limit: 10000K Total Submissions: 24918 Accepted: 12909 DescriptionGiven a two-dimensional array of positive and negative integers, a sub-rectangle

2011-03-09 18:37:00 385

原创 POJ 1702 Eva's Balance 三进制

<br /> 三进制 <br /><br /> <br />/*Eva's BalanceTime Limit: 1000MS Memory Limit: 10000K Total Submissions: 3155 Accepted: 1567 DescriptionEva has a balance with 20 poises. The weights of the poises are 1, 3, 9, 27,...,3^19. Eva asserts that she

2011-03-09 18:35:00 676

原创 POJ 1012 Joseph

<br /><br /> <br />/*JosephTime Limit: 1000MS Memory Limit: 10000K Total Submissions: 33497 Accepted: 12550 DescriptionThe Joseph's problem is notoriously known. For those who are not familiar with the original problem: from among n people, n

2011-03-09 18:34:00 750 1

原创 POJ 1258 Agri-Net Kruskal算法

<br />Kruskal算法.<br /><br />#include "stdlib.h"#include "stdio.h"#include "string.h"#define MAX_SET_NODE_NUM 101typedef struct _SET_NODE_ST_ { int iRoot; int iRank;}SET_NODE_ST;typedef struct _EDGE_ST_{ int iVertexX; int iVert

2011-03-08 23:03:00 468

原创 POJ 1475 Pushing Boxes 推箱子游戏

<br />两个BFS。<br />尝试使用A*算法,但由于使用stl的priority_queue,效率太低,不能满足时限要求。<br /> <br /><br />/*Pushing BoxesTime Limit: 2000MS Memory Limit: 131072K Total Submissions: 2966 Accepted: 1084 Special Judge DescriptionImagine you are standing inside a two

2011-03-03 18:08:00 1669

原创 POJ 2676 Sudoku 数独游戏

<br />DFS.<br /><br />/*SudokuTime Limit: 2000MS Memory Limit: 65536K Total Submissions: 7686 Accepted: 3757 Special Judge DescriptionSudoku is a very simple task. A square table with 9 rows and 9 columns is divided to 9 smaller squares 3x3

2011-03-02 18:32:00 889

原创 POJ 1182 食物链 并查集

<br />英文:Disjoint Set,即“不相交集合” 将编号分别为1…N的N个对象划分为不相交集合, <br />在每个集合中,选择其中某个元素代表所在集合。<br />常见两种操作:1.合并两个集合; 2. 查找某元素属于哪个集合 .所以,也称为“并查集”<br /><br /> <br />/*食物链Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 20989 Accepted: 6059 Descripti

2011-03-01 23:54:00 449

原创 POJ 1085 Triangle War 极小极大值算法+α-β剪枝

<br />用极小极大值算法解决比较直观,但是效率太低,即使使用了α-β剪枝,效率仍然很低,勉强ACCEPT,<br />因为这种方法本质上是深度搜索,会有大量的重复计算,如果像DP那样将计算过的状态记录下来,则还有进一步优化的空间。<br /><br />/*Triangle WarTime Limit: 1000MS Memory Limit: 65536K Total Submissions: 1567 Accepted: 623 DescriptionTriangle W

2011-02-28 18:15:00 1804

原创 POJ 3253 Fence Repair Huffman

<br />利用贪心算法中的Huffman解决。<br /><br /> <br />/*Fence RepairTime Limit: 2000MS Memory Limit: 65536K Total Submissions: 10280 Accepted: 3279 DescriptionFarmer John wants to repair a small length of the fence around the pasture. He measures the fe

2011-02-27 12:38:00 640

原创 POJ 1077 Eight A*算法 八数码问题

可以使用A*算法解决。启发函数f(n)=g(n)+h(n),h(n)=所有棋子到其目标位置的距离和*K,也就是曼哈顿距离*K。经过验证,k=1时会超出POJ的时限,k=4时最快,但K=4得到的结果其实不能最短路径,如下面例子:8 6 7 2 5 4 3 x 1K=1:  ruuldlurddlurrulldrdruldlururddK=2:  urulldrrdluulddruruldldrruldluurrddK=4:ruulddrulldruldrrululddruurddluruldlurrddluu

2011-02-26 19:16:00 1400

原创 POJ 2449 Remmarguts' Date A*算法

求第K短路径。在A*算法中,求最短路径时,当从优先级队列中取到目的节点时就结束了,为了求K短路径,则不结束,继续从优先级队列中取节点,直到第K次取到目的节点就是第K短路径。为了使用A*算法,首先要得到启发函数 f(n)=g(n)+h(n), 其中f(n) 是从初始点经由节点n到目标点的估价函数,g(n) 是在状态空间中从初始节点到n节点的实际代价,g(n)可以在A*算法过程中得到,h(n)是从n到目标节点最佳路径的估计代价,也就是目标节点到其他所有节点的距离,需要通过其他算法(如Dijkstra、Spfa)

2011-02-25 19:24:00 1204

原创 POJ 1061 青蛙的约会

<br />求解模线性方程:a*x = b(mod n)。参见《算法导论》P533.<br /> <br /><br /> <br />/*青蛙的约会Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 56557 Accepted: 8577 Description两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面。它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到碰面为止。可是它们出发

2011-02-20 15:46:00 779 2

原创 POJ 1011 Sticks

<br />搜索+剪枝。<br /><br />/*SticksTime Limit: 1000MS Memory Limit: 10000K Total Submissions: 78763 Accepted: 17360 DescriptionGeorge took sticks of the same length and cut them randomly until all parts became at most 50 units long. Now he wants

2011-02-19 22:10:00 744

原创 POJ 2050 Searching the Web

<br />hash.<br /><br /> <br /> <br /> <br /> /*Searching the WebTime Limit: 5000MS Memory Limit: 65536K Total Submissions: 1670 Accepted: 367 DescriptionThe word "search engine" may not be strange to you. Generally speaking, a search engine s

2011-02-18 13:20:00 1032

原创 POJ 1013 Counterfeit Dollar

<br />逻辑问题。<br />如果为even,则确定为真币;否则为怀疑状态:Light or Heavy,<br />如果既被怀疑为Light又被怀疑为Heavy,则也确定为真币;<br />否则被怀疑次数最多的硬币为假币。<br /> <br /><br /> <br />/*Counterfeit DollarTime Limit: 1000MS Memory Limit: 10000K Total Submissions: 27895 Accepted: 8723 Descri

2011-02-16 17:38:00 569

原创 POJ 1338 Ugly Numbers 寻找丑数

寻找丑数动态规划,比较简单,直接参见下面的代码。/*Ugly NumbersTime Limit: 1000MS Memory Limit: 10000K Total Submissions: 13272 Accepted: 5856 DescriptionUgly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence 1, 2, 3, 4, 5, 6, 8, 9, 10, 12,

2011-02-15 23:10:00 620

原创 POJ 1160 Post Office

<br />状态方程gaDistance[m][n] = min{gaDistance[m-1][t] + gaiSumDistance[t+1][n] }<br />gaiSumDistance[t][n]表示在t到n站间设立一个邮局所能达到的最小和;<br /> <br /><br /> <br />/*Post OfficeTime Limit: 1000MS Memory Limit: 10000K Total Submissions: 9956 Accepted: 5341 D

2011-02-14 18:17:00 707

原创 POJ 2411 Mondriaan's Dream

<br />用00表示2*1的长方形,11表示1*2的长方形,<br />则每一行的每一个状态对下一行的状态有要求,gastStateLimit[][i]表示某行第i种状态对下一行的各种要求。<br />最后一行没有“凸出”,也就是对“下一行”没有要求,因此也就是统计最后一行各个状态对下一行没有要求的总数。<br /><br />/*Mondriaan's DreamTiHeighte LiHeightit: 3000MS Memory LiHeightit: 65536K Total Submi

2011-02-12 14:49:00 491

原创 POJ 1185 炮兵阵地

<br />gaiStateDp[i][j][k] = max{gaiStateDp[i-1][k][p]+c[j]},(枚举p的每种状态) <br />gaiStateDp[i][j][k]表示第i行状态为aiState[j],第i-1行状态为aiState[k]的最大炮兵数,且aiState[j],aiState[k],aiState[p]及地形之间互不冲突.<br /> <br /><br />/*炮兵阵地Time Limit: 2000MS Memory Limit: 65536K Tot

2011-02-10 23:22:00 651 1

原创 POJ 3254 Corn Fields

<br />记录状态的DP.<br />每一行的状态有2^12种可能(其中一部分状态是无效的),且与前一行的状态相关,<br />题目要求计算的可以理解为到达最后一行各个有效状态的次数之和。<br />输入1 for fertile, 0 for infertile,为了计算方便进行取反,0 for fertile, 1 for infertile。<br /><br /><br />/*Corn FieldsTime Limit: 2000MS Memory Limit: 65536K Tota

2011-02-10 14:26:00 711

原创 POJ 2739 Sum of Consecutive Prime Numbers

<br />将一个数分解为连续素数的和。<br /><br />/*Sum of Consecutive Prime NumbersTime Limit: 1000MS Memory Limit: 65536K Total Submissions: 10186 Accepted: 5777 DescriptionSome positive integers can be represented by a sum of one or more consecutive prime n

2011-02-08 00:49:00 467

原创 POJ 2262 Goldbach's Conjecture

<br />素数的判断。<br /><br />/*Goldbach's ConjectureTime Limit: 1000MS Memory Limit: 65536K Total Submissions: 21888 Accepted: 8714 DescriptionIn 1742, Christian Goldbach, a German amateur mathematician, sent a letter to Leonhard Euler in which he

2011-02-08 00:42:00 452

原创 POJ 3006 Dirichlet's Theorem on Arithmetic Progressions

<br />素数的判断。<br /><br />/*Dirichlet's Theorem on Arithmetic ProgressionsTime Limit: 1000MS Memory Limit: 65536K Total Submissions: 9253 Accepted: 4617 DescriptionIf a and d are relatively prime positive integers, the arithmetic sequence begin

2011-02-08 00:34:00 363

原创 POJ 1083 Moving Tables

<br />要注意细节:如图,当room3占用时,room4是不能同时占用的。<br />比如,2--> 3 ,4-->5不能同时进行。<br /><br /> <br /><br />/*Moving TablesTime Limit: 1000MS Memory Limit: 10000K Total Submissions: 15537 Accepted: 5067 DescriptionThe famous ACM (Advanced Computer Maker) Co

2011-02-08 00:28:00 434

原创 POJ 3176 Cow Bowling

<br />DP。<br /><br />/*Cow BowlingTime Limit: 1000MS Memory Limit: 65536K Total Submissions: 8030 Accepted: 5248 DescriptionThe cows don't use actual bowling balls when they go bowling. They each take a number (in the range 0..99), though, an

2011-02-08 00:17:00 508

原创 POJ 2255 Tree Recovery

<br />通过二叉树的前序和中序遍历结果,计算出后续遍历结果。<br />思路为拆分成左子树和右子树进行递归。<br /><br />可以恢复出二叉树后再后续遍历,也可以在重建过程中进行输出,这里为了代码供以后参考,重建了二叉树,并在过程中打印输出。<br /> <br /><br /> <br />/*Tree RecoveryTime Limit: 1000MS Memory Limit: 65536K Total Submissions: 5033 Accepted: 3350

2011-02-08 00:08:00 714

原创 POJ 2159 Ancient Cipher

<br /><br /> <br />/*Ancient CipherTime Limit: 1000MS Memory Limit: 65536K Total Submissions: 16407 Accepted: 5659 DescriptionAncient Roman empire had a strong government system with various departments, including a secret service department.

2011-02-01 22:17:00 1355

原创 POJ 1836 Alignment

<br />DP.思路:<br />1.求递增子序列的长度,递减子序列的长度;<br />2.然后找一个中间点,把两个序列连在一起,形成一个先递增后递减的子序列,也就是留下来的序列,<br />3.目标是要留下来的个数最大。<br />gaiAscendingHeight[I]表示从0~i的最长递增子序列的长度;<br />gaiDescendingHeight[I]表示从i~len-1的最长递减子序列的长度;<br /> <br /><br /> <br />/*AlignmentTime Lim

2011-02-01 12:25:00 530

原创 POJ 3267

<br />DP问题。<br />思路:<br />每个字符有两种情况:作为单词首字母和不作为单词首字母。<br />gaiRemovedNum[i]表示从i开始到结尾需要删除的字符数;<br />gaiRemovedNum[i] = MIN(将第i的字符作为首字母匹配时需要删除的字符数 , 1 + gaiRemovedNum[i+1]);<br />(1 + gaiRemovedNum[i+1])是i不作为首字母时需要删除的字符数。<br />从最后一个字符开始扫描,则gaiRemovedNum[0]即为

2011-01-31 11:15:00 826

原创 POJ 1014

<br />与POJ 1276差不多,首先求总和,若为奇数则不可分,若为偶数,求出其一半.然后求出一半是否由这些相加可达.<br /> <br /><br /> <br />/*DividingTime Limit: 1000MS Memory Limit: 10000K Total Submissions: 35222 Accepted: 8641 DescriptionMarsha and Bill own a collection of marbles. They want

2011-01-30 00:26:00 593

原创 POJ 1276

<br />多重背包问题,并使用二进制分物品.<br /> <br /><br /> <br /> <br />/*Cash MachineTime Limit: 1000MS Memory Limit: 10000K Total Submissions: 14301 Accepted: 4836 DescriptionA Bank plans to install a machine for cash withdrawal. The machine is able to del

2011-01-29 18:34:00 651

原创 POJ 1837

<br />DP问题。<br />1.阶段:每放置一个weight为一个阶段;<br />2.状态:每个阶段的“力矩”和作为状态(这里“力矩”为weight*position);<br />3.状态转移:每个阶段有若干种可能状态,求出下一阶段的所有可能状态并计算到达每个状态的次数;<br />4.目标:最后一个阶段的时,到达状态“0”的次数;<br /><br /> <br />/*BalanceTime Limit: 1000MS Memory Limit: 30000K Total Submi

2011-01-28 11:40:00 832

原创 POJ 2406

<br />利用KMP算法的预处理部分。<br /> <br /><br /> <br />/*Power StringsTime Limit: 3000MS Memory Limit: 65536K Total Submissions: 15324 Accepted: 6475 DescriptionGiven two strings a and b we define a*b to be their concatenation. For example, if a = "ab

2011-01-26 18:57:00 1312

原创 poj 3984

<br />可以使用广搜、DIJKSTRA等算法。<br />这里使用的是DIJKSTRA算法。<br /> <br /><br /> <br /> <br />源代码:<br />/*迷宫问题Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 1392 Accepted: 771 Description定义一个二维数组: int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1

2011-01-25 12:31:00 544

原创 poj 1067

<br /><br /> <br /> <br />/*取石子游戏Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 21772 Accepted: 6753 Description有两堆石子,数量任意,可以不同。游戏开始由两个人轮流取石子。游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子;二是可以在两堆中同时取走相同数量的石子。最后把石子全部取完者为胜者。现在给出初始的两堆石子的数目,如果轮

2011-01-24 18:16:00 332

原创 poj 1002

/*487-3279Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 150071 Accepted: 25565 DescriptionBusinesses like to have memorable telephone numbers. One way to make a telephone number memorable is to have it spell a memorable word or p

2011-01-20 23:50:00 332

原创 PKU ACM poj 1459 源代码

<br />最大流问题,采用Ford-Fulkerson算法。<br />在初始化的时候记录每个点的正向邻节点和反向邻节点,并增加一个源点和一个汇点. <br />开始使用DFS搜索增广路径,结果会超时,<br />改用BFS搜索,则可以ACCEPT,也就是要使用Edmonds-Karp算法。<br />另外,在输入时要使用int型的变量,否则会出现错误。<br /><br /> <br />/*Power NetworkTime Limit: 2000MS Memory Limit: 32768K

2011-01-20 15:58:00 323

原创 PKU ACM poj 2231 源代码

简单题,关键是提高效率。使用暴力计算,耗时1000ms,改进算法后为63ms,然后再改进程序中的细节,进而优化到16ms。源代码(16MS):#include "stdlib.h"#include "stdio.h"#define MAX_COW_NUM 10000typedef struct _COW_ST_ { int iLocation;/*in the range 0..1,000,000,000*/}COW_ST;typedef struct _M

2011-01-15 00:19:00 492

Sukodu 数独游戏软件及源代码

自己写的一个数独游戏小软件。 点击“新游戏”生成一个新游戏,如图1,玩家填入剩余空格,软件有提示功能,如果输入错误,方格背景变为红色,正确则变为绿色。 点击“显示答案”则给出当前情况的答案,如图2. 点击“手动输入”,然后再输入他处看到的题目,然后点击“显示答案”则可以解答,如图3.图4.。

2011-03-09

UML和模式应用(经典图书)

UML和模式应用 UML和模式应用 UML和模式应用 UML和模式应用

2010-11-27

TD-基本原理-李世鹤

TD-基本原理-李世鹤 ppt..........

2010-11-16

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除