![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
文章平均质量分 58
lightblueme
Hello Programmers!
展开
-
poj 1163 lightblueme 三角形的最大路径和
#include #include #include int max(int a,int b){ if(a>b) return a; return b;}int nums[105][105];int pathsize[105][105];int main(){ int col; int i,j; scanf("%d",&col); for(i=0;i<col;i+原创 2013-01-23 17:04:33 · 375 阅读 · 0 评论 -
zoj 1002
下面是我参考的别人的代码:(来自洞庭散人)http://www.cnblogs.com/phinecos/archive/2008/09/18/1293017.html#includeusing namespace std;char map[4][4];// 地图int maxNum,n;bool CanPut(int row,int col){//测试是否原创 2013-01-19 17:02:57 · 222 阅读 · 0 评论 -
poj 3299 Humidex lightblueme
#include #include #include //careful careful careful careful careful careful //careful careful careful careful careful careful//careful careful careful careful careful careful//careful car原创 2013-01-19 13:28:38 · 369 阅读 · 0 评论 -
POJ 2159 Ancient Cipher lightblueme
#include #include #include #include int cmp(const void * a,const void * b){ return *(int*)a-*(int*)b;} int main(){ char str1[105]; char str2[105]; scanf("%s",str1); scanf("%原创 2013-01-18 14:18:02 · 280 阅读 · 0 评论 -
oj 2746 约瑟夫问题
#include #include int flag[305];void init(){ for(int index=0;index<305;index++){ flag[index]=0; }}int main(){ int n,m; scanf("%d",&n); scanf("%d",&m); while(n!=0&&m!=0){ int index=-1;原创 2013-02-03 10:14:18 · 599 阅读 · 0 评论 -
poj 2349 最小生成树 careful everything!
#include #include #include #include using namespace std;#define NUM 505typedef struct{ int x,y;}Node;Node nodes[NUM];typedef struct{ int from; int to; double cost;}Edge;int cmp(con原创 2013-01-31 21:16:30 · 425 阅读 · 0 评论 -
poj 2075 lightblueme double qsort cmp函数的写法
对于int类型的数据使用qsort可以为:int a,b;int cmp(){ return a-b;}而对于double类型int a,b;if(a>b) return 1;if(a==b) return 0;else return -1;poj 2075 code#include #include #include #原创 2013-01-30 21:23:15 · 379 阅读 · 0 评论 -
poj 1258 prim lightblueme
对于标准的矩阵输入使用矩阵作为存储结构可以简化算法的设计。#include #include #include using namespace std;#define NUM 105int costmatrix[NUM][NUM];int flag[NUM];void init(){ for(int index=0;index<NUM;index++){ flag[i原创 2013-01-29 13:31:05 · 355 阅读 · 0 评论 -
POJ 1258 lightblueme Agri Net angry!89次的失误终于得到最后的成功
低级错误,困扰了我整整两天!kruskal方法用于求最小生成树,对于属于不同set的节点进行合并时需要找到相应的set的根节点root1和root2,将root1的父节点指针指向root2或者相反。切莫只是改变当前节点的指针。就是这个低级的错误是我同提交了89次才终于成功!89次!!#include #include #define NUM 105typedef struct原创 2013-01-26 22:41:52 · 290 阅读 · 0 评论 -
poj 1088 lightblueme 最佳的滑雪路径
经典的动态规划问题#include #include #include int length[105][105];int height[105][105];struct heap{ int r,c,height;};int shift[4][2]={ {0,1}, {0,-1}, {1,0}, {-1,0}};heap heaps[1原创 2013-01-23 15:49:20 · 247 阅读 · 0 评论 -
poj 百练 Intervals 区间覆盖
算法的思想:首先对于所有的节点根据起始坐标按照从小到大进行排序。定义两个变量from和to,分别记录前一个区间的起始坐标和停止坐标。然后看下一个节点:(from1,to1)case 1:if(from1>=to) then 合并from不变;to修改为to和to1中的较大者。case 2:if(from1and update the from and to#include #原创 2013-02-15 19:41:43 · 415 阅读 · 0 评论