自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(15)
  • 收藏
  • 关注

原创 字典树(trie)简介以及两种实现

字典树的两种实现

2016-12-09 22:39:10 402

原创 POJ 1192 最优连通子集(树上DP)

题目链接:http://poj.org/problem?id=1192题意:给出一个由平面整点构成的树(两点相邻当且仅到曼哈顿距离为1),有N个点,每个点有权值。求这棵树的权值最大的子树(只求这个子树的权值)思路:用树上DP解决。称所要求的权值最大子树为“最大集”首先要把这个树看成一个有根树。对于每个节点,维护两个数,分别是该子树中最大集的权值,和包含当前这个节点的最大集的权值

2016-12-08 22:45:44 712

原创 POJ 1322 Chocolate(母函数)

题目链接:http://poj.org/problem?id=1322题意:经过简单转化,我们需要解决一个这样的问题:每一次从C样东西里面随机选一种,一共选N次,求恰有M种东西被选了基数次的概率。数据范围:C思路一:简单DPdp[m][n]表示选了n次之后恰好有m种东西出现奇数次的概率。状态转移为dp[m][n+1]=dp[m+1][n]*(m+1)/C+dp[m-1][n]*

2016-12-05 21:50:07 741

原创 POJ 1191 棋盘分割(DP)

Description将一个8*8的棋盘进行如下分割:将原棋盘割下一块矩形棋盘并使剩下部分也是矩形,再将剩下的部分继续如此分割,这样割了(n-1)次后,连同最后剩下的矩形棋盘共有n块矩形棋盘。(每次切割都只能沿着棋盘格子的边进行) 原棋盘上每一格有一个分值,一块矩形棋盘的总分为其所含各格分值之和。现在需要把棋盘按上述规则分割成n块矩形棋盘,并使各矩形棋盘总分的均方差最小。 

2016-11-30 22:54:00 261

原创 POJ 1157 LITTLE SHOP OF FLOWERS(DP)

DescriptionYou want to arrange the window of your flower shop in a most pleasant way. You have F bunches of flowers, each being of a different kind, and at least as many vases ordered in a row. Th

2016-11-29 23:39:50 213

原创 POJ 1143 Number Game(状压DP)

DescriptionChristine and Matt are playing an exciting game they just invented: the Number Game. The rules of this game are as follows. The players take turns choosing integers greater than 1. Fi

2016-11-29 23:09:12 222

原创 POJ 1018 Communication System(贪心+优化)

题目描述:有n种仪器,第i种仪器有m_i个供应商,不同供应商提供的同一种仪器有不同的带宽(B)和价格(p), n种仪器总带宽为所有仪器带宽最小值。要求从每种仪器的供应商中选一个,使得最终总带宽除以总价格最小。限制:n思路:网上说这是一个DP。如果给出了带宽的范围则可以用DP做,但是题目中并没有给出上界。我的做法是从所有仪器中选出一个,用它的带宽作为所有仪器的瓶颈,然后从带宽更大的仪器中每种

2016-11-29 19:16:09 1056

原创 UVa 908 Re-connecting Computer Sites

Consider the problem of selecting a setT of high-speed lines for connectingN computer sites, from auniverse ofM high-speed lines each connecting a pair of computer sites. Each high-speed line ha

2016-11-24 22:25:42 405

原创 中缀表达式转换为后缀表达式

问题:给出一个表达式,含有括号,将其转化成后缀表达式输出算法:用栈维护将要输出的运算符(operator)读入一个token1)如果是数,直接输出2)如果是运算符(不含括号),比较其与栈顶元素优先级若栈顶元素同级或更高级,则将其出栈并输出,直到栈为空或者栈顶运算符级别更低3)如果是左括号'(', 则将其入栈4)如果是右括号')', 则将栈顶元素依次出栈并输出,直到有匹配

2016-11-23 18:13:52 257

原创 UVa 10810 Ultra-QuickSort(逆序对)

题目描述:给出n个整数,求其逆序对个数。数据范围:n分析:使用归并排序求逆序对/* PROG: UVa10810*/#include #include #include using namespace std;#define MAXN 500010int a[MAXN], b[MAXN], c[MAXN];#define DEBUG 1#define LOG(

2016-11-23 14:32:47 281

原创 UVa 146 ID Codes (next_permutation函数)

It is 2084 and the year of Big Brother has finally arrived, albeit a century late. In order to exercise greater control over its citizens and thereby to counter a chronic breakdown in law and order, t

2016-11-22 14:27:06 205

原创 UVa 11340 Newspaper

News agency pays money for articles according to some rules. Each character has its own value (somecharacters may have value equals to zero). Author gets his payment as a sum of all character’s values

2016-11-22 14:09:07 222

原创 UVa 10392 Factoring Large Numbers(分解因数)

One of the central ideas behind much cryptography is that factoring large numbers is computationallyintensive. In this context one might use a 100 digit number that was a product of two 50 digit prime

2016-11-22 00:15:12 282

原创 UVa 10061 How many zero's and how many digits

Given a decimal integer number you will have to find out how many trailing zeros will be there in itsfactorial in a given number system and also you will have to find how many digits will its factoria

2016-11-21 23:31:49 236

原创 C/C++ 常用字符串函数总结

C/C++ 常用字符串函数总结

2016-11-11 21:21:43 981

空空如也

空空如也

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

TA关注的人

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