
挑战程序设计
RPG_Zero
春日雨,夏蝉鸣,明天是个好天气。
秋风起,雪花轻,海底看不见四季。
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
POJ 1001 Exponentiation 求高精度幂
题目链接DescriptionProblems involving the computation of exact values of very large magnitude and precision are common. For example, the computation of the national debt is a taxing experience for many...原创 2019-08-31 14:57:14 · 223 阅读 · 0 评论 -
AOJ 0189 Convenient Location 最短路 Floyd-Warshall算法
题目大意:求某一个办公室 到其他所有办公室的 总距离最短 办公室数不超过10(编号为0~9)输入:多组输入,每组第一行为n (1 ≤ n ≤ 45),接下来n行是 (x, y, d),x到y的距离是d输出:办公室号 和 总的最短距离解题思路:基础的Floyd-Warshall算法AC代码:#include<iostream>#include<algorith...原创 2019-08-22 10:29:48 · 242 阅读 · 0 评论 -
动态规划 背包问题小结 0-1背包(采药 九度第101题) 完全背包(Piggy-Bank POJ 1384) 多重背包(珍惜现在,感恩生活 九度第103题)
本小结介绍0-1背包、完全背包以及多重背包问题记忆要点:0-1背包:二维数组情况下,顺序遍历体积或者倒序均可以 降维情况下需倒序遍历体积完全背包:数组降维+顺序遍历多重背包:进行类似于二进制分解的操作,然后转化为...原创 2019-08-16 21:25:56 · 401 阅读 · 2 评论 -
AOJ 2170 Marked Ancestor 并查集 好题! 有助于理解路径压缩的意义
You are given a tree T that consists of N nodes. Each node is numbered from 1 to N, and node 1 is always the root node of T. Consider the following two operations on T:M v: (Mark) Mark node v.Q v: ...原创 2019-08-21 22:12:42 · 281 阅读 · 0 评论 -
POJ 1703 Find them, Catch them 种类并查集
题目链接Find them, Catch themTime Limit: 1000MS Memory Limit: 10000KDescriptionThe police office in Tadu City decides to say ends to the chaos, as launch actions to root up the TWO gangs in...原创 2019-08-21 17:10:56 · 248 阅读 · 0 评论 -
POJ 2229 Sumsets 解题报告 动态规划
DescriptionFarmer John commanded his cows to search for different sets of numbers that sum to a given number. The cows use only numbers that are an integer power of 2. Here are the possible sets of ...原创 2019-08-12 20:02:40 · 319 阅读 · 0 评论 -
POJ 3181 Dollar Dayz 完全背包 高精度dp 大数
DescriptionFarmer John goes to Dollar Days at The Cow Store and discovers an unlimited number of tools on sale. During his first visit, the tools are selling variously for $1, $2, and $3. Farmer Joh...原创 2019-08-16 15:21:56 · 200 阅读 · 0 评论 -
最小生成树小结(MST问题) Kruskal 算法 Prim算法 POJ 1258 HDOJ 1233
Kruskal 算法Prim算法原创 2019-08-25 19:24:22 · 418 阅读 · 0 评论 -
POJ 3176 Cow Bowling 入门级动态规划
DescriptionThe cows don’t use actual bowling balls when they go bowling. They each take a number (in the range 0…99), though, and line up in a standard bowling-pin-like triangle like this: ...原创 2019-08-12 16:57:07 · 153 阅读 · 0 评论 -
POJ 2236 Wireless Network 并查集
题目链接Wireless NetworkTime Limit: 10000MS Memory Limit: 65536KDescriptionAn earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless netw...原创 2019-08-21 11:45:33 · 182 阅读 · 0 评论 -
POJ 3262 Protecting the Flowers 贪心比率
DescriptionFarmer John went to cut some wood and left N (2 ≤ N ≤ 100,000) cows eating the grass, as usual. When he returned, he found to his horror that the cluster of cows was in his garden eating ...原创 2019-08-12 15:36:53 · 216 阅读 · 0 评论 -
POJ 3046 Ant Counting dp 经典多重集合数问题模型 优化递推关系式
DescriptionBessie was poking around the ant hill one day watching the ants march to and fro while gathering food. She realized that many of the ants were siblings, indistinguishable from one another...原创 2019-08-15 20:34:43 · 266 阅读 · 0 评论 -
AOJ 2200 Mr. Rito Post Office Floyd+DP
题目链接题目是日文的。。。下面是参考的其他博客中的题目大意:你有一个当邮递员的好基友利腾桑遇到麻烦了:全岛有一些镇子通过水路和旱路相连,走水路必须要用船,在X处下船了船就停在X处。而且岛上只有一条船,下次想走水路还是得回到X处才行;两个镇子之间可能有两条以上的水路或旱路;邮递员必须按照清单上的镇子顺序送快递(镇子可能重复,并且对于重复的镇子不允许一次性处理,比如ABCB的话B一定要按顺序走...原创 2019-08-25 10:33:29 · 268 阅读 · 0 评论 -
POJ 2010 Moo University - Financial Aid 优先队列 好题!
题目链接DescriptionBessie noted that although humans have many universities they can attend, cows have none. To remedy this problem, she and her fellow cows formed a new university called The Universit...原创 2019-08-20 22:22:26 · 175 阅读 · 0 评论 -
POJ 1862 Stripies 贪心
DescriptionOur chemical biologists have invented a new very useful form of life called stripies (in fact, they were first called in Russian - polosatiki, but the scientists had to invent an English ...原创 2019-08-12 10:10:18 · 194 阅读 · 0 评论 -
POJ 3614 Sunscreen(贪心 优先队列)有助于理解贪心过程
题目链接DescriptionTo avoid unsightly burns while tanning, each of the C (1 ≤ C ≤ 2500) cows must cover her hide with sunscreen when they’re at the beach. Cow i has a minimum and maximum SPF rating (1 ...原创 2019-08-20 19:12:16 · 608 阅读 · 2 评论 -
POJ 2139 Six Degrees of Cowvin Bacon 最短路
题目链接Sample Input4 23 1 2 32 3 4Sample Output100题目大意:给定 n, m.之后m行,每行是一个集合。每一个集合里任意两个元素之间的距离都是1.最后求出一个点,这个点到其余所有点的距离和最小,即求ans令 ∑dis[ans][i] 最小 (1=<i<=n 且i不等于ans)然后输出平均距离(乘100倍保留整数)...原创 2019-08-22 11:38:16 · 143 阅读 · 0 评论 -
POJ 1065 Wooden Sticks 贪心+动态规划之单调递增子序列
DescriptionThere is a pile of n wooden sticks. The length and weight of each stick are known in advance. The sticks are to be processed by a woodworking machine in one by one fashion. It needs some ...原创 2019-08-17 22:30:30 · 207 阅读 · 0 评论 -
POJ 1631 Bridging signals 最长上升子序列小结 LIS的O(nlogn)算法
POJ 1631 Bridging signals题目分析:题目要求避免相交,则可转化为对给定的序列求最长上升子序列。首先使用了dp来求解,复杂度为O(n*n),在题目的数据范围下超时了…#include<iostream>#include<stdio.h>#include<algorithm>using namespace std;int dp...原创 2019-08-18 12:30:58 · 250 阅读 · 0 评论 -
POJ 3233 Matrix Power Series 矩阵快速幂
题目链接Matrix Power SeriesTime Limit: 3000MS Memory Limit: 131072KDescriptionGiven a n × n matrix A and a positive integer k, find the sum S = A + A^2 + A^3 + … + A^k.InputThe input contains exac...原创 2019-08-30 15:09:12 · 224 阅读 · 0 评论 -
POJ 3734 Blocks 矩阵快速幂
题目链接DescriptionPanda has received an assignment of painting a line of blocks. Since Panda is such an intelligent boy, he starts to think of a math problem of painting. Suppose there are N blocks in...原创 2019-08-29 21:39:07 · 186 阅读 · 0 评论 -
POJ 3070 Fibonacci 矩阵快速幂模板
题目链接题目大意:求第n项的斐波那契数对10000求余的结果解题思路:矩阵快速幂模板题矩阵快速幂模板://用二维vector来表示矩阵typedef vector<int> vec;typedef vector<vec> mat;typedef long long ll;const int M = 10000;//计算矩阵相乘mat mul(mat ...原创 2019-08-29 19:42:27 · 198 阅读 · 0 评论 -
POJ 1995 Raising Modulo Numbers 快速幂模板题
题目链接DescriptionPeople are different. Some secretly read magazines full of interesting girls’ pictures, others create an A-bomb in their cellar, others like using Windows, and some like difficult ma...原创 2019-08-28 21:13:08 · 173 阅读 · 0 评论 -
POJ 3641 Pseudoprime numbers 快速幂+判断素数 快速幂模板
题目链接DescriptionFermat’s theorem states that for any prime number p and for any integer a > 1, ap = a (mod p). That is, if we raise a to the pth power and divide by p, the remainder is a. Some (b...原创 2019-08-28 20:19:43 · 179 阅读 · 0 评论 -
POJ 3292 Semi-prime H-numbers 素数筛法变种
DescriptionThis problem is based on an exercise of David Hilbert, who pedagogically suggested that one study the theory of 4n+1 numbers. Here, we do only a bit of that.An H-number is a positive num...原创 2019-08-28 11:06:51 · 193 阅读 · 0 评论 -
POJ 3421 X-factor Chains 分解素因数+排列组合
题目链接DescriptionGiven a positive integer X, an X-factor chain of length m is a sequence of integers,1 = X0, X1, X2, …, Xm = XsatisfyingXi < Xi+1 and Xi | Xi+1 where a | b means a perfectly div...原创 2019-08-27 21:41:48 · 292 阅读 · 0 评论 -
POJ 3126 Prime Path 素数筛法+BFS STL中pair模板使用
DescriptionThe ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all have to change the four-digit room numbers on their offices.— It is a ...原创 2019-08-27 15:48:34 · 240 阅读 · 0 评论 -
AOJ 0009 Prime Number 素数筛法 模板题
Write a program which reads an integer n and prints the number of prime numbers which are less than or equal to n. A prime number is a natural number which has exactly two distinct natural number div...原创 2019-08-27 12:03:11 · 598 阅读 · 0 评论 -
POJ 1930 Dead Fraction 无限循环小数化分数 数论+枚举
题目链接DescriptionMike is frantically scrambling to finish his thesis at the last minute. He needs to assemble all his research notes into vaguely coherent form in the next 3 days. Unfortunately, he n...原创 2019-08-27 11:26:10 · 341 阅读 · 0 评论 -
AOJ 0005 GCD and LCM 最大公约数和最小公倍数入门
Write a program which computes the greatest common divisor (GCD) and the least common multiple (LCM) of given a and b.InputInput consists of several data sets. Each data set contains a and b separa...原创 2019-08-26 16:27:06 · 192 阅读 · 0 评论 -
POJ 2395 Out of Hay 寻找最小生成树中的最长边 Kruskal算法
题目链接题目大意:有N个农场,M条路连通各个农场,要求走遍全部的农场,且每走1单位长度就要消耗一单位水,每到一个农场就可以补充水,求在所走的总路径最短的情况下最小的水箱容量。解题思路:寻找最小生成树中的最长边,下面代码中使用的是Kruskal算法AC代码:#include<iostream>#include<stdio.h>#include<algor...原创 2019-08-26 15:05:52 · 279 阅读 · 0 评论 -
AOJ 2224 Save your cats 最小生成树 Kruskal算法
题目链接题目大意:很多猫被栅栏围了起来,每个栅栏的两端是两个站桩,每组输入有n个站桩和m个栅栏,首先给出每个站桩的坐标,然后给出连接每一个栅栏的两个点,问如何破坏栅栏使消耗最小(即边最小)并且解救出所有被围起来的猫解题思路:本题的意思有些难理解,实质是给你一个连通图,图中有一些环,要求去掉一些边,使得该图不再有环。我们的目的是要破坏原本图中的这些环,最大生成树刚好可以满足没有环的条件...原创 2019-08-26 14:47:49 · 218 阅读 · 0 评论 -
POJ 2377 Bad Cowtractors 最大生成树 Kruskal
DescriptionBessie has been hired to build a cheap internet network among Farmer John’s N (2 <= N <= 1,000) barns that are conveniently numbered 1…N. FJ has already done some surveying, and fou...原创 2019-08-26 11:24:34 · 239 阅读 · 0 评论 -
POJ 3259 Wormholes Bellman-Ford算法模板题 SPAF模板题
题目链接WormholesTime Limit: 2000MS Memory Limit: 65536KDescriptionWhile exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole is very peculiar b...原创 2019-08-23 10:39:23 · 412 阅读 · 0 评论 -
AOJ 2249 Road Construction Dijkstra变种
题目链接King Mercer is the king of ACM kingdom. There are one capital and some cities in his kingdom. Amazingly, there are no roads in the kingdom now. Recently, he planned to construct roads between th...原创 2019-08-24 10:07:42 · 215 阅读 · 0 评论 -
POJ 3040 Allowance 贪心
DescriptionAs a reward for record milk production, Farmer John has decided to start paying Bessie the cow a small weekly allowance. FJ has a set of coins in N (1 <= N <= 20) different denomina...原创 2019-08-11 15:25:15 · 193 阅读 · 0 评论 -
Osenbei AOJ 0525 DFS 穷竭搜索
题目大意是讲一个烧饼铺,在一个n * m (1<=n<=10,1<=m<=10000)的烤桌上面摆着一堆烧饼,数字1表示烧饼正面,0表示烧饼反面。然后你每次可以将一整行或者一整列的烧饼翻面,即正面翻成反面或者反面翻成正面。但是必须是一整列或者一整行的翻,问最多可以使都少烧饼翻成正面?Sample input2 50 1 0 1 01 0 0 0 13 61 0...原创 2019-08-05 08:11:20 · 195 阅读 · 0 评论 -
AOJ0118 Property Distribution 简单DFS
题意简述:财产分割问题。H×W的区间,种有苹果(@)、柿子(#)和桔子(※)的树。问同类水果树连片的共有多少片?sample input10 10####*****@@#@@@@#*#*@##***@@@*#****#*@**##@*#@@*##*@@@@*@@@#***#@*@##**@@@*@@##@*@*#*@##**@****#@@#@0 0sample ...原创 2019-07-27 11:48:57 · 259 阅读 · 0 评论 -
POJ 2718 Smallest Difference 全排列函数next_permutation再尝试
DescriptionGiven a number of distinct decimal digits, you can form one integer by choosing a non-empty subset of these digits and writing them in some order. The remaining digits can be written down...原创 2019-07-31 15:00:09 · 168 阅读 · 0 评论 -
Millionaire(2008 APAC local onsites c) 概率dp
题意:最开始你有x元钱,要进行M轮赌博。每一轮赢的概率为P,你可以选择赌与不赌,如果赌也可以将所持的任意一部分钱作为赌注(可以是整数,也可以是小数)。如果赢了,赌注将翻倍;输了赌注则没了。在M轮赌博结束后,如果你持有的钱在100万元以上,就可以把这些钱带回家。问:当你采取最优策略时,获得100万元以上的钱并带回家的概率是多少。samples:input:M = 1, P = 0.5, X ...原创 2019-07-26 12:26:15 · 798 阅读 · 0 评论