![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
030-图论
蒝味
这个作者很懒,什么都没留下…
展开
-
poj-1751-Highways-(最小生成树)
HighwaysTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 6078 Accepted: 1650 Special JudgeDescriptionThe island nation of Flatopia is perfectly flat. U原创 2013-01-11 14:32:16 · 4652 阅读 · 0 评论 -
poj 2192-动态规划-DP
ZipperTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 13940 Accepted: 4871DescriptionGiven three strings, you are to determine whether the third strin原创 2013-03-20 17:48:09 · 670 阅读 · 0 评论 -
poj- 1321-棋子问题-dfs
算是水题吧。。简单的dfs搜索:题目:给出不规则的棋盘,#表示棋盘区域,然后在上面摆放棋子,问你有几种放法#include #include using namespace std;const int maxn = 8;char MAP[maxn][maxn];int n, k, cnt;bool vis[maxn];void dfs(int x, int cur){原创 2013-04-04 10:53:03 · 574 阅读 · 0 评论 -
zoj 3332-Strange Country II-dfs
DescriptionYou want to visit a strange country. There are n cities in the country. Cities are numbered from 1 to n. The unique way to travel in the country is taking planes. Strangely, in this str原创 2013-04-05 16:39:38 · 1621 阅读 · 0 评论 -
poj -2560-Freckles-最小生成树
In an episode of the Dick Van Dyke show, little Richie connects the freckles on his Dad's back to form a picture of the Liberty Bell. Alas, one of the freckles turns out to be a scar, so his Ripley'原创 2013-04-05 16:18:25 · 1980 阅读 · 0 评论 -
poj 2377-prim(最小生成树的最大边权的和)
Bad CowtractorsTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 9094 Accepted: 3894DescriptionBessie has been hired to build a cheap internet network amo原创 2013-03-23 10:00:12 · 824 阅读 · 0 评论 -
Uva 10608- 并查集,最大的朋友个数
Problem IFRIENDS There is a town with N citizens. It is known that some pairs of people are friends. According to the famous saying that “The friends of my friends are my friends, too” it fo原创 2013-04-06 19:47:23 · 946 阅读 · 0 评论 -
poj 1941-递归
#include #include #include #include #include #include #include #include #include #define setbit(x,y) x|=(1<<(y)) //将X的第Y位置1#define clrbit(x,y) x&=~(1<<(y)) //将X的第Y位清0#define sf scanf#defi原创 2013-03-24 09:58:10 · 979 阅读 · 1 评论 -
hdu 2066-dijkstra
有n个起点和m个终点,求出从家到火车站的最短的距离dijkstra代码:#include #include #include #include #include #include #include #include #include #define setbit(x,y) x|=(1<<(y)) //将X的第Y位置1#define clrbit(x,y) x&=~原创 2013-03-23 18:44:41 · 568 阅读 · 0 评论 -
差分约束
最近想学习差分约了。。整理一下资料吧 所谓差分约束系统,是指一组不定方程(A,x,T,b),其中A的每行有一个1,一个-1,其余为0,x为解向量,T为=组成的向量,b为约束矢量。具体来说,就是每行都具有 xi-xj >=| 假设一个系统由n个变量和m和约束条件组成,约束条件形如:xj - xi 类似于最短路中的三角不等式:dis[j] 因此,以每原创 2013-04-07 20:56:50 · 717 阅读 · 0 评论 -
hdu 2072-单词数
题意:小文章都是由小写字母和空格组成,没有标点符号,统计一篇文章里不同单词的总数。做这个题目学习了STL的学习,set以及string的一点应用:具体的看代码:#include #include #include #include // 不要忘记了 using namespace std; int main() { string art;原创 2013-03-31 10:36:55 · 3714 阅读 · 2 评论 -
uva 11426-欧拉函数
Problem JGCD Extreme (II)Input: Standard InputOutput: Standard Output Given the value of N, you will have to find the value of G. The definition of G is given below:原创 2013-03-16 21:43:55 · 799 阅读 · 0 评论 -
poj-Out of Hay-最小生成树的最大边权
Out of HayTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 8973 Accepted: 3409DescriptionThe cows have run out of hay, a horrible event that must be remedi原创 2013-01-10 22:32:35 · 710 阅读 · 0 评论 -
poj-2485-Highways-最小生成树的最大权边
HighwaysTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 17064 Accepted: 7975DescriptionThe island nation of Flatopia is perfectly flat. Unfortunately, Fla原创 2013-01-10 22:20:33 · 1369 阅读 · 0 评论 -
hdu 2063过山车-二分图
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=2063过山车Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5907 Accepted Submission(s):原创 2013-02-01 20:32:36 · 2353 阅读 · 0 评论 -
poj 2645-Boastin' Red Socks-算组合
题意:给你p和q,表示从一个黑箱中一次取两只袜子,两只都是红袜子的概率是p/q。。问你箱子里要多少红袜子和黑袜子?解析:首先明确p/q是怎么来的。我们假设总的袜子数量是i,红袜子的数量是j,p/q就是C(j,2)/C(i,2);即 j(j-1)/(i*(i-1))=p/q;此时枚举i,来计算j的值。。注意:若i*(i-1)=tmp,要求出i的话:就是i=(int)sqrt(tm原创 2013-02-25 09:24:30 · 1036 阅读 · 2 评论 -
hdu 2119 Matrix-二分图
poj 3041F - MatrixTime Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uSubmit Status Practice HDU 2119DescriptionGive you a matrix(only contains 0 or 1原创 2013-02-01 22:07:33 · 505 阅读 · 0 评论 -
poj 2945-关于字符串的排序
Find the ClonesTime Limit: 5000MS Memory Limit: 65536KTotal Submissions:6265 Accepted: 2328DescriptionDoubleville, a small town in Texas, was attacked by the al原创 2013-02-28 14:25:05 · 625 阅读 · 0 评论 -
poj 2895-字符串的处理
做这个题目的收获就是:知道了gets(str)的作用。可以忽略掉字符串里面的空格。。。还有就是,字符数组可以保存字符的大小Best SMS to TypeTime Limit: 1000MS Memory Limit: 65536KTotal Submissions:3768 Accepted: 1584Descr原创 2013-02-28 15:31:03 · 499 阅读 · 0 评论 -
poj 2253 Frogger-Flody(关于坐标距离的处理)
FroggerTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 19357 Accepted: 6301DescriptionFreddy Frog is sitting on a stone in the middle of a lake. Sudde原创 2013-03-01 09:58:40 · 463 阅读 · 0 评论 -
并查集
参考:http://dongxicheng.org/structure/union-find-set/原创 2013-03-15 19:26:27 · 602 阅读 · 0 评论 -
差分约束2
转载注明出处:http://www.cppblog.com/abilitytao/archive/2009/08/21/94061.html(本文假设读者已经有以下知识:最短路径的基本性质、Bellman-Ford算法。) 比如有这样一组不等式: X1 - X2 X1 - X5 X2 - X5 X3 - X1 X4 - X1 X4 - X3转载 2013-04-07 21:01:13 · 534 阅读 · 0 评论 -
hdu 1548-A strange lift-最短路-dijkstra
DescriptionThere is a strange lift.The lift can stop can at every floor as you want, and there is a number Ki(0 <= Ki <= N) on every floor.The lift have just two buttons: up and down.When you at f原创 2013-04-08 21:38:07 · 635 阅读 · 0 评论 -
hdu-3592-World Exhibition-差分约束
DescriptionNowadays, many people want to go to Shanghai to visit the World Exhibition. So there are always a lot of people who are standing along a straight line waiting for entering. Assume that原创 2013-04-08 23:21:07 · 634 阅读 · 0 评论 -
最近题目基础练习
1、计算一个数在不同的进制下的阶乘的位数阶乘位数的公式:log(xy) = log(x) + log(y), 所以100的阶乘:log(1) + log(2) + ....log(100)最后转化成不同的进制:最后除以log(base)后 +1 就好了(base指的是进制)需要注意的是,开数组的时候要开double,否则是错的代码:double a[1000005] = {0}原创 2013-05-21 12:21:11 · 571 阅读 · 0 评论 -
poj-3628-Bookshelf 2
题目意思:有个书架,高度为H,现在FJ有N个奶牛,每个奶牛有个高度hi,现在将奶牛堆起来,使得堆起来的高度大于等于H,现在要求最小高度差。B - Bookshelf 2Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64uSubmit Status Prac原创 2013-05-11 09:19:08 · 870 阅读 · 0 评论 -
CodeForces 102A - flody
I - ClothesTime Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64uSubmit Status Practice CodeForces 102ADescriptionA little boy Gerald entered a clothes sho原创 2013-05-11 17:49:48 · 811 阅读 · 0 评论 -
UVA 10000 -Longest Paths-Bellman - Ford,flody,spfa
\A - Longest PathsTime Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %lluSubmit Status Practice UVA 10000Description Longest Paths原创 2013-05-11 18:05:02 · 1471 阅读 · 0 评论 -
UVA 10006
题目意思:快速幂求摸。。。。G - Carmichael NumbersTime Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %lluSubmit Status Practice UVA 10006Description Carmi原创 2013-05-12 09:04:01 · 1506 阅读 · 0 评论 -
算一个日期是星期几
F - What day is itTime Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uSubmit Status Practice HDU 2133DescriptionToday is Saturday, 17th Nov,2007. Now, if原创 2013-05-30 00:55:30 · 839 阅读 · 0 评论 -
poj 2506-计算方格摆放的方法数
D - TilingTime Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64uSubmit StatusDescriptionIn how many ways can you tile a 2xn rectangle by 2x1 or 2x2 tiles?原创 2013-06-12 19:29:37 · 1111 阅读 · 0 评论 -
POJ 1308-判断是不是一棵树
B - Is It A Tree?Time Limit:1000MS Memory Limit:10000KB 64bit IO Format:%I64d & %I64uSubmit Status Practice POJ 1308DescriptionA tree is a well-known data structure tha原创 2013-07-23 10:30:35 · 920 阅读 · 0 评论 -
poj 2226-二分图的最小顶点覆盖
二分图最小顶点覆盖:参考连接:http://ip96cns.blog.163.com/blog/static/170095192201117465473/此题大意就是 在一块方格上有'*'和'.',要用木板覆盖'*',同时不能覆盖'.',木板宽度为1,长度不定,木板间可以相互覆盖。问最少要用多少个木板。 从题目中直接举个用例,再不明白请去看题目。 Sa原创 2013-03-19 18:25:30 · 751 阅读 · 0 评论 -
poj 3041-Asteroids-最小顶点覆盖
AsteroidsTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 11259 Accepted: 6107DescriptionBessie wants to navigate her spaceship through a dangerous aster原创 2013-03-19 20:05:15 · 787 阅读 · 0 评论 -
poj 3164-最小树形图
参考博文:http://www.cnblogs.com/nanke/archive/2012/04/11/2441725.htmlF - Command NetworkTime Limit:1000MS Memory Limit:131072KB 64bit IO Format:%I64d & %I64uSubmit Status Practic原创 2013-04-29 10:40:19 · 707 阅读 · 0 评论 -
poj- 1948- Triangular Pastures-DP
Like everyone, cows enjoy variety. Their current fancy is new shapes for pastures. The old rectangular shapes are out of favor; new geometries are the favorite. I. M. Hei, the lead cow pasture arc原创 2013-04-09 20:39:09 · 992 阅读 · 0 评论 -
poj-3624-Charm Bracelet0-1背包
DescriptionBessie has gone to the mall's jewelry store and spies a charm bracelet. Of course, she'd like to fill it with the best charms possible from the N (1 ≤ N ≤ 3,402) available charms. Each原创 2013-04-09 23:01:41 · 1971 阅读 · 0 评论 -
hdu-1598-最佳路线的舒适度最高速与最低速的差-并查集
XX星有许多城市,城市之间通过一种奇怪的高速公路SARS(Super Air Roam Structure---超级空中漫游结构)进行交流,每条SARS都对行驶在上面的Flycar限制了固定的Speed,同时XX星人对 Flycar的“舒适度”有特殊要求,即乘坐过程中最高速度与最低速度的差越小乘坐越舒服 ,(理解为SARS的限速要求,flycar必须瞬间提速/降速,痛苦呀 ),但XX星人对时间原创 2013-04-12 19:17:15 · 1019 阅读 · 0 评论 -
poj - 2186- 强连通 - 最受欢迎的牛的个数
刘汝佳的书上有详细的介绍, 并且这个代码几乎和书上的是一样的强连通就是“相互到达的关系”,每一个集合称为有向图的一个强连通分量。如果把每一个集合看成一个点,那么所有SCC构成一个SCC图,这个SCC图不会存在有向环,因此是一个DAG------------------"缩点"此题用了个定理 :有向无环图(DAG)中,从任意一个点出发,必定可以到达某一个出度为0的点。这个不用原创 2013-04-22 17:59:20 · 827 阅读 · 0 评论 -
几个最短路径算法Floyd、Dijkstra、Bellman-Ford、SPFA的比较
转载自:http://blog.csdn.net/v_july_v/article/details/6181485几大最短路径算法比较 July、二零一一年二月十二日。----------------------------------- 几个最短路径算法的比较:Floyd 求多源、无负权边的最短路。用矩阵记录图。时效性较差,时转载 2013-04-23 23:48:13 · 940 阅读 · 0 评论