07 2015 档案

UVA-10497 Sweet Child Makes Trouble (计数+高精度)
摘要:题目大意:这是一道简单排列组合题 。简单说下题意:n件物品,把这n件物品放到不是原来的位置,问所有的方案数。所有的位置都没有变。题目解析:按照高中的方法,很快得到一个递推公式:f [n]= (n-1)*( f [n-1] + f [n-2] ) 。这个公式也不难理解,可以采取这样的策咯:一件物品一件... 阅读全文

posted @ 2015-07-29 20:41 20143605 阅读(350) 评论(0) 推荐(0)

UVA-11584 Partitioning by Palindromes (简单线性DP)
摘要:题目大意:给一个全是小写字母的字符串,判断最少可分为几个回文子序列。如:“aaadbccb” 最少能分为 “aaa” “d” “bccb” 共三个回文子序列,又如 “aaa” 最少能分为 1 个回文子序列。题目解析:状态转移方程 dp[i]=min(dp[j]+1) , 其中,j -> i 是回文子... 阅读全文

posted @ 2015-07-29 20:17 20143605 阅读(169) 评论(0) 推荐(0)

HDU-3631 Shortest Path (floyd)
摘要:Description When YY was a boy and LMY was a girl, they trained for NOI (National Olympiad in Informatics) in GD team. One day, GD team’s coach, Prof. ... 阅读全文

posted @ 2015-07-28 12:59 20143605 阅读(200) 评论(0) 推荐(0)

HDU-1232 畅通工程 (并查集、判断图中树的棵数)
摘要:Description某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路?Input 测试输入包含若干测试用例。每个测试用例... 阅读全文

posted @ 2015-07-28 09:54 20143605 阅读(234) 评论(0) 推荐(0)

HDU-1272 小希的迷宫 (并查集、判断图是否为树)
摘要:Description 上次Gardon的迷宫城堡小希玩了很久(见Problem B),现在她也想设计一个迷宫让Gardon来走。但是她设计迷宫的思路不一样,首先她认为所有的通道都应该是双向连通的,就是说如果有一个通道连通了房 间A和B,那么既可以通过它从房间A走到房间B,也可以通过它从房间B走到房... 阅读全文

posted @ 2015-07-28 09:47 20143605 阅读(192) 评论(0) 推荐(0)

POJ-1511 Invitation Cards (双向单源最短路)
摘要:Description In the age of television, not many people attend theater performances. Antique Comedians of Malidinesia are aware of this fact. They want ... 阅读全文

posted @ 2015-07-28 09:36 20143605 阅读(1136) 评论(0) 推荐(0)

HDU-3790 最短路径问题(双重权值)
摘要:Problem Description给你n个点,m条无向边,每条边都有长度d和花费p,给你起点s终点t,要求输出起点到终点的最短距离及其花费,如果最短距离有多条路线,则输出花费最少的。Input输入n,m,点的编号是1~n,然后是m行,每行4个数 a,b,d,p,表示a和b之间有一条边,且其长度为... 阅读全文

posted @ 2015-07-28 09:25 20143605 阅读(188) 评论(0) 推荐(0)

Graph (floyd)
摘要:DescriptionEveryone knows how to calculate the shortest path in a directed graph. In fact, the opposite problem is also easy. Given the length of shor... 阅读全文

posted @ 2015-07-28 09:18 20143605 阅读(145) 评论(0) 推荐(0)

POJ-3259 Wormholes(判断负环、模板)
摘要:DescriptionWhile exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole is very peculiar because it is a one-w... 阅读全文

posted @ 2015-07-28 09:07 20143605 阅读(148) 评论(0) 推荐(0)

HDU-1317 XYZZY
摘要:Description It has recently been discovered how to run open-source software on the Y-Crate gaming device. A number of enterprising designers have deve... 阅读全文

posted @ 2015-07-28 08:59 20143605 阅读(408) 评论(0) 推荐(0)

HDU-1548 A strange lift(单源最短路 或 BFS)
摘要:Problem DescriptionThere is a strange lift.The lift can stop can at every floor as you want, and there is a number Ki(0 2 # include 3 # include 4 # i... 阅读全文

posted @ 2015-07-26 19:38 20143605 阅读(159) 评论(0) 推荐(0)

最小生成树(模板 prim)
摘要:Description省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可)。现得到城镇道路统计表, 表中列出了任意两城镇间修建道路的费用,以及该道路是否已经修通的状态。现请你编写程序,计算出全省畅通需要的最低成本。Input 测试输... 阅读全文

posted @ 2015-07-26 10:28 20143605 阅读(986) 评论(0) 推荐(0)

最小生成树(模板 Kruskal)
摘要:Description某省调查乡村交通状况,得到的统计表中列出了任意两村庄间的距离。省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可),并要求铺设的公路总长度为最小。请计算最小的公路总长度。Input 测试输入包含若干测试用例。每... 阅读全文

posted @ 2015-07-26 10:24 20143605 阅读(1900) 评论(0) 推荐(0)

基础最短路(模板 spfa)
摘要:Description虽然草儿是个路痴(就是在杭电待了一年多,居然还会在校园里迷路的人,汗~),但是草儿仍然很喜欢旅行,因为在旅途中 会遇见很多人(白马王子,^0^),很多事,还能丰富自己的阅历,还可以看美丽的风景……草儿想去很多地方,她想要去东京铁塔看夜景,去威尼斯看电影,去 阳明山上看海芋,去纽... 阅读全文

posted @ 2015-07-26 10:16 20143605 阅读(519) 评论(0) 推荐(0)

基础最短路(模板 dijkstra)
摘要:Description 某省自从实行了很多年的畅通工程计划后,终于修建了很多路。不过路多了也不好,每次要从一个城镇到另一个城镇时,都有许多种道路方案可以选择,而某些方案要比另一些方案行走的距离要短很多。这让行人很困扰。 现在,已知起点和终点,请你计算出要从起点到终点,最短需要行走多少距离。 ... 阅读全文

posted @ 2015-07-26 10:04 20143605 阅读(740) 评论(0) 推荐(0)

基础最短路(模板 bellman_ford)
摘要:Description在每年的校赛里,所有进入决赛的同学都会获得一件很漂亮的t-shirt。但是每当我们的工作人员把上百件的衣服从商店运回到赛场的时候,却是非常累的!所以现在他们想要寻找最短的从商店到赛场的路线,你可以帮助他们吗?Input 输入包括多组数据。每组数据第一行是两个整数N、M(N 2 ... 阅读全文

posted @ 2015-07-26 09:57 20143605 阅读(367) 评论(0) 推荐(0)

UVA-12304 Race(递推)
摘要:题目大意:求n个人比赛的所有可能的名次种数。比如:n=2时,有A第一B第二、B第一A第二、AB并列第一三种名次。题目解析:既然是比赛,总有第一名。第一名的人数可能是i (1≤i≤n),则剩下待定的人数就是n-i......设 f(n)为n个人比赛时的名次种数。则 f(n)= ∑ C(n,i)f(n-... 阅读全文

posted @ 2015-07-26 09:44 20143605 阅读(438) 评论(0) 推荐(0)

How do you add?(递推)
摘要:题意:求将n分为k个数相加的种数。如:n=20,k=2,则可分为:0+20=201+19=202+18=20.......20 +0=20共21种方案。解析:令f(n,m)表示将n分为m个数相加的种数,则 f(n,m)= ∑ f(n-i,m-1) (0 ≤ i ≤n)代码如下: 1 # includ... 阅读全文

posted @ 2015-07-26 09:26 20143605 阅读(229) 评论(0) 推荐(0)

Coconuts, Revisited(递推+枚举+模拟)
摘要:DescriptionThe short story titled Coconuts, by Ben Ames Williams, appeared in the Saturday Evening Post on October 9, 1926. The story tells about five... 阅读全文

posted @ 2015-07-24 10:20 20143605 阅读(297) 评论(0) 推荐(0)

UVA-10726 Coco Monkey(递推)
摘要:题目大意:n个人,m个猴子分桃,第一个人把桃子分成n份余下m个,第一个人将余下的给猴子,拿走自己的那份。第二个人把剩下的桃子也分成n份,余下m个,将余下的分给猴子,拿走自己的那份。………… 直到n个人如此做完之后,剩下的桃子数正好是能被n个人平分。求在区间[l,r]中,有几个值可能是原来的桃子数。题... 阅读全文

posted @ 2015-07-24 10:05 20143605 阅读(176) 评论(0) 推荐(0)

UVA-10995 Educational Journey
摘要:The University of Calgary team qualified for the 28th ACM International Collegiate Programming Contest World Finals in Prague, Czech Republic. Just by... 阅读全文

posted @ 2015-07-24 09:38 20143605 阅读(144) 评论(0) 推荐(0)

UVA-10339 Watching Watches
摘要:题目大意:有两个钟表,开始时都指向00:00,但是一个每天慢m秒,另一个每天慢k秒,问两个表再次指向同一时刻时的所指时间。精确到分钟,四舍五入。题目解析:先求出再次指向同一时间时实际经过的天数,天数d=12*3600/abs(m-k)。然后可求每个表总共慢下来的秒数,余下不再细说,看代码。注意:求时... 阅读全文

posted @ 2015-07-24 08:35 20143605 阅读(241) 评论(0) 推荐(0)

UVA-11029 Leading and Trailing
摘要:Apart from the novice programmers, all others know that you can’t exactly represent numbers raised to some high power. For example, the C function pow... 阅读全文

posted @ 2015-07-23 08:52 20143605 阅读(621) 评论(0) 推荐(1)

UVA-11752 The Super Powers
摘要:We all know the Super Powers of this world and how they manage to get advantages in political warfare or even in other sectors. But this is not a poli... 阅读全文

posted @ 2015-07-22 20:13 20143605 阅读(354) 评论(0) 推荐(0)

CodeForces 558B
摘要:DescriptionAmr has got a large array of size n. Amr doesn't like large arrays so he intends to make it smaller.Amr doesn't care about anything in the ... 阅读全文

posted @ 2015-07-22 13:20 20143605 阅读(345) 评论(0) 推荐(0)

CodeForces 558A
摘要:DescriptionAmr lives in Lala Land. Lala Land is a very beautiful country that is located on a coordinate line. Lala Land is famous with its apple tree... 阅读全文

posted @ 2015-07-22 13:11 20143605 阅读(192) 评论(0) 推荐(0)

Hardly Hard
摘要:You have been given the task of cutting out a quadrilateral slice of cake out of a larger, rectangular cake. You must find the slice with the smallest... 阅读全文

posted @ 2015-07-22 12:50 20143605 阅读(179) 评论(0) 推荐(0)