自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(29)
  • 问答 (1)
  • 收藏
  • 关注

原创 poj3264 poj3468 poj2528【线段树】

线段树    操作:    区间分解(LogN):        如果有某个节点代表的区间完全属于待分解区间,则该节点为“终止节点” 不再继续向下分解。        所有终止节点不重叠,加在一起恰等于整个待分解区间。     伪代码:    function (根节点pRoot,查询区间[l,r]){ if(查询区间恰等于节点表示区间)

2013-07-17 00:11:41 406

原创 poj2243 【搜索】【深度优先】

本解中 对于每个起点进行深度优先搜索 记录到每一个点的最短路径。  #includeusing namespace std;int knight[8][8];int x[]={1,1,2,2,-1,-1,-2,-2};int y[]={2,-2,1,-1,2,-2,1,-1};void DFS(int si,int sj,int moves){ if

2013-06-30 15:27:01 417

原创 poj 1222 【枚举】【遍历搜索】

本题可以用高斯消元法求解。 或者使用如下方法进行遍历搜索。 1.枚举第一行的情况:可能是 0 0 0 0 0 0              1 0 0 0 0 0              0 1 0 0 0 0               ……              1 1 1 1 1 1 2.如果按照第一行的熄灯方法 可以将灯全部熄灭 则找到答案

2013-06-30 14:28:32 439

原创 poj 1258 【最小生成树】【prim】【纯模板】

就是模板- -熟练起来#includeusing namespace std;const int inf = 0x3f3f3f3f;int p[100][100];int vis[100];int lowc[100];void input(int n){ for(int i=0;i<n;i++) for(int j=0;j<n;j++)

2013-06-14 16:07:07 377

原创 poj 3176 1163【动态规划】【入门】

典型动态规划入门问题。状态转移方程为dp[i][j]=p[i][j]+max{dp[i+1][j],dp[i+1][j+1]}#include#define M 110#define max(a,b) a>b?a:bint dp[M][M];int main(){ int n; scanf("%d",&n); for(int i=1; i<=n; i++){

2013-06-13 01:04:37 413

原创 poj 2503 【hash】【map】

对两个字符串变量进行映射。完成查找,输出。使用STL的map容器。 注意string对象的操作,与char数组间的转换,及容器的操作方法#include#include#includeusing namespace std;mapMap;string str1,str2;char str[100],c_str1[50],c_str2[50];

2013-06-13 00:43:22 503

原创 poj 2388 Who's in the Middle【sort排序】

简单题特别基本的sort排序,注意cmp函数的写法  #include #include #include #include using namespace std;typedef struct{ int MakeMilk; int num;}COW;COW cow[10005];bool cmp(COW A,COW B);int m

2013-06-13 00:32:46 355

原创 poj 1936 All in All 【串】

题目大意:输入两个字符串,如果字符串1包含在字符串2中(不必须是子串) 输出YES 否则输出 NO 没什么好说的 ,控制循环即可。#includeusing namespace std;char str1[100000],str2[100000];int main(){ while(scanf("%s %s",&str1,&str2)!=EOF){ int

2013-06-13 00:27:11 245

原创 poj 2109 【贪心?】

题意:输入n,p两个数字,求k,使得kn = p.没什么说的,用double可以直接水过,不明白这道题为什么归类为贪心。 #include#includeusing namespace std;int main(){ double n,m; while(cin>>n>>m) { n=(double)pow(m,1/n)

2013-06-13 00:11:26 941

原创 poj 3253 【哈夫曼树】【优先队列】

#include#includeusing namespace std;struct cmp1{ bool operator ()(long long &a,long long &b){ return a>b;//最小值优先 }}; priority_queue,cmp1>pq;int main(){ long l

2013-06-12 22:50:50 345

转载 STL map

关于STL中map的用法剖析【完整版】1 map概述    STL(Standard Template Library 标准模版库)是C++标准程序库的核心,它深刻影响了标准程序库的整体结构。STL是一个范型(generic)程序库,提供一系列软件方案,利用先进、高效的算法来管理数据。STL的好处在于封装了许多数据结构和算法(algorithm),map就是其典型代表。

2013-05-07 13:04:22 324

原创 poj 1700 【乘船问题】【动态规划】

题意:n个人坐船过河,只有一条船,每条船能坐两个人,过河的时间取决于两个人中最慢的一个,问过河最快共需多少时间? 先使d[0...n-1]有序; 则           d[0]表示过河最快的        d[1]表示过河次快的 对于每一个i,        d[i]    表示当前过河最慢的         d[i-1] 表示当前过河次慢的dp[0]

2013-04-30 11:08:34 791

原创 poj 2533 【动态规划】【最大上升子序列】

求最大上升子序列问题老师今天上课刚讲过的问题 。用动态规划求解。 dp[0]=1;dp[i]=max{dp[j](0  #includeusing namespace std;int d[10010];int dp[10010];int n;void getdp(){ dp[0]=1; for(int i=1;i<n;i++){ int

2013-04-28 13:10:26 432

转载 poj 1260 Pearls 【动态规划】

转载请注明出处:優YoU  http://user.qzone.qq.com/289065406/blog/1300164274大致题意:给出几类珍珠,以及它们的单价,要求用最少的钱就可以买到相同数量的,相同(或更高)质量的珍珠。【规定买任一类的珍珠n个(价格为p),都要支付(n+10)*p的钱,即额外支付10*p】 例如样例Input的第二个例子:31 101

2013-04-26 12:57:40 344

转载 POJ 2192

文章作者:Yx.Ac   文章来源:勇幸|Thinking(http://www.ahathinking.com) 题意:就是给定三个字符串A,B,C;判断C能否由AB中的字符组成,同时这个组合后的字符顺序必须是A,B中原来的顺序,不能逆序;例如:A:mnl,B:xyz;如果C为mnxylz,就符合题意;如果C为mxnzly,就不符合题意,原因是z与y顺序不是B中顺序。DP求解:定

2013-04-23 20:26:07 419

原创 poj 1577 二叉查找树

题意: 将一棵二叉查找树的所有叶子节点去掉(Falling Leaves) 按照顺序用一个字符串给出 再将剩下的树如上操作,直到根节点被作为字符串给出。 任务是还原这棵树,并先根遍历输出。 一道入门的二叉查找树问题 ,主要就是考查插入操作。关键还是要注意字符型二维数组的操作。之前就是因为忘了给内循环计数器归零 调试了好久才解决。  #includeu

2013-04-23 19:16:06 464

原创 poj 2083 分形

FractalTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 6514 Accepted: 3226DescriptionA fractal is an object or quantity that displays self-similarity, in

2013-04-20 21:29:06 559

原创 poj 1338 打表

Ugly NumbersTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 17737 Accepted: 7866DescriptionUgly numbers are numbers whose only prime factors are 2, 3 or 5

2013-04-18 21:18:21 268

原创 poj2159 字符串

Ancient CipherTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 23921 Accepted: 7990DescriptionAncient Roman empire had a strong government system with vari

2013-04-16 19:24:23 239

原创 poj 1129 dfs

Channel AllocationTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 10540 Accepted: 5369DescriptionWhen a radio station is broadcasting over a very large ar

2013-04-11 20:01:19 416

原创 poj 2752 KMP

Seek the Name, Seek the FameTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 9153 Accepted: 4338DescriptionThe little cat is so famous, that many couples t

2013-04-10 20:47:44 282

原创 poj 1256 next_permutation

AnagramTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 16165 Accepted: 6589DescriptionYou are to write a program that has to generate all possible words f

2013-04-08 18:48:52 355

原创 poj 2244

Eeny Meeny MooTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 2907 Accepted: 1999DescriptionSurely you have made the experience that when too many people

2013-04-08 12:18:55 454

原创 poj 1844 数学问题

SumTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 9591 Accepted: 6281DescriptionConsider the natural numbers from 1 to N. By associating to each number a

2013-04-07 19:00:30 451

原创 poj 1833

排列Time Limit: 1000MS Memory Limit: 30000KTotal Submissions: 13979 Accepted: 5712Description题目描述: 大家知道,给出正整数n,则1到n这n个数可以构成n!种排列,把这些排列按照从小到大的顺序(字典顺序)列出,如n=3时,列出1 2

2013-04-07 18:09:20 324

原创 poj 1163

The TriangleTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 32155 Accepted: 19016Description73 88 1 02 7 4 44 5 2 6 5(

2013-04-07 16:27:16 278

原创 poj 2104 (qsort cmp)

K-th NumberTime Limit: 20000MS Memory Limit: 65536KTotal Submissions: 30949 Accepted: 9484Case Time Limit: 2000MSDescriptionYou are working for Macrohard comp

2013-04-07 16:22:56 282

原创 poj 1519

Digital RootsTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 24050 Accepted: 7970DescriptionThe digital root of a positive integer is found by summing the

2013-04-07 16:11:21 351

原创 poj 2141

Message DecowdingTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 10878 Accepted: 6016DescriptionThe cows are thrilled because they've just learned about e

2013-04-07 13:10:09 348

空空如也

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

TA关注的人

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