04 2017 档案

摘要:POJ.1995 Raising Modulo Numbers (快速幂)提议分析快速幂裸题 分别给出递归写法和位运算写法。 感觉位运算应该会更快一点,实际上这两个跑的一样快。不知道为什么(摊手代码总览#include #include #include #include #incl... 阅读全文
posted @ 2017-04-30 22:40 pengwill 阅读(94) 评论(0) 推荐(0)
摘要:POJ.3172 Scales (DFS)题意分析一开始没看数据范围,上来直接01背包写的。RE后看数据范围吓死了。然后写了个2^1000的DFS,妥妥的T。 后来想到了预处理前缀和的方法。细节以注释的方式给出。代码总览#include #include #include #incl... 阅读全文
posted @ 2017-04-30 18:13 pengwill 阅读(100) 评论(0) 推荐(0)
摘要:URAL.1033 Labyrinth (DFS)题意分析WA了好几发,其实是个简单地DFS。意外发现这个俄国OJ,然后发现ACRUSH把这个OJ刷穿了。代码总览#include #include #include #include #include #include #includ... 阅读全文
posted @ 2017-04-30 17:25 pengwill 阅读(95) 评论(0) 推荐(0)
摘要:POJ.3278 Catch That Cow (BFS)题意分析求最少的操作次数,暴力就用BFS。 这题坑点挺多,一开始交上去无限RE,摸不着头脑,后来发现后数组越界了。因为存在-1的操作和*2的操作 ,不加判断就直接越界。 这告诉我们一个道理,光把数组开大点,是没有用的。代码总览... 阅读全文
posted @ 2017-04-30 17:18 pengwill 阅读(98) 评论(0) 推荐(0)
摘要:并查集是我暑假从高手那里学到的一招,觉得真是太精妙的设计了。以前我无法解决的一类问题竟然可以用如此简单高效的方法搞定。不分享出来真是对不起party了。(party:我靠,关我嘛事啊?我跟你很熟么?) 来看一个实例,杭电1232畅通工程 首先在地图上给你若干个城镇,这些城镇都可以看作... 阅读全文
posted @ 2017-04-30 12:19 pengwill 阅读(159) 评论(0) 推荐(0)
摘要:CodeForces - 158B.Taxi (贪心)题意分析首先对1234的个数分别统计,4人组的直接加上即可。然后让1和3成对处理,只有2种情况,第一种是1多,就让剩下的1和2组队处理,另外一种是3多,那么结果就加上3的个数,再单独处理2. 对于1和2组队处理的讨论:首先分配2,... 阅读全文
posted @ 2017-04-29 22:34 pengwill 阅读(197) 评论(0) 推荐(0)
摘要:CodeForces - 50A Domino piling (贪心+递归)题意分析奇数*偶数=偶数,如果两个都为奇数,最小的奇数-1递归求解,知道两个数都为1,返回0。代码#include #include #include #include #include #include #... 阅读全文
posted @ 2017-04-29 22:28 pengwill 阅读(314) 评论(0) 推荐(0)
摘要:CodeForces.158A Next Round (水模拟)题意分析校赛水题的英文版,坑点就是要求为正数。代码总览#include #include #include #include #include #include #include #include #include #i... 阅读全文
posted @ 2017-04-29 22:25 pengwill 阅读(151) 评论(0) 推荐(0)
摘要:CodeForces71A. Way Too Long Words (水模拟)题意分析题怎么说你怎么做 没有坑点代码总览#include #include #include #include #include #include #include #include #include #... 阅读全文
posted @ 2017-04-29 22:22 pengwill 阅读(207) 评论(0) 推荐(0)
摘要:AOJ.849 分数 (暴力)题意分析每次枚举分子,然后根据给出的分数值,推算出来分母,然后取分母上下几个数进行进一步计算,看看哪个更接近。 一开始想着直接枚举分子和分母,复杂度爆炸。。。代码总览#include #include #include #define INF 0x3f3... 阅读全文
posted @ 2017-04-28 21:30 pengwill 阅读(137) 评论(0) 推荐(0)
摘要:AOJ.850 电缆公司的烦恼 (二分+枚举)题意分析从[1,average]二分枚举长度即可,由于保留2位小数,可以将数据扩大10^2倍后后枚举,输出时除100即可。代码总览#include #include #include #include #include #include ... 阅读全文
posted @ 2017-04-28 21:26 pengwill 阅读(161) 评论(0) 推荐(0)
摘要:AOJ.859 地毯填补问题 (递归与分治)题意分析学习分治思想,第一次接触,代码总览#include #include #include #include #include #include #include #include #include #include #define I... 阅读全文
posted @ 2017-04-28 21:19 pengwill 阅读(278) 评论(0) 推荐(0)
摘要:AOJ.865 青铜莲花池 (BFS)题意分析典型的BFS 没的说代码总览#include #include #include #include #include #include #include #include #include #include #define INF 0x3... 阅读全文
posted @ 2017-04-28 21:14 pengwill 阅读(283) 评论(0) 推荐(0)
摘要:题意分析现有n个人,n种书,给出每人对n种书的喜欢列表,求有多少种方案满足以下条件: 1.每个人都分得自己喜欢的书; 2.每个人分得书的种类各不相同,即所有种类的书均得到分配 1.采用生成测试法 生成过程 对于每个人来说,枚举每本书的状态(0/1),有2^20; ... 阅读全文
posted @ 2017-04-28 21:11 pengwill 阅读(167) 评论(0) 推荐(0)
摘要:AOJ.866 飞越原野 (三维BFS)题意分析点我挑战题目 相比于普通的BFS,要多一维来记录当前剩余的体力。而且还要额外的一层循环来处理,飞过的路程。代码总览#include #include #include #include #include #include #includ... 阅读全文
posted @ 2017-04-28 21:05 pengwill 阅读(526) 评论(0) 推荐(0)
摘要:UVA.129 Krypton Factor (搜索+暴力)题意分析搜索的策略是:优先找长串,若长串不合法,则回溯,继续找到合法串,直到找到所求合法串的编号,输出即可。 注意的地方就是合法串的判断,根据后缀的规则来判断,枚举后缀长度[1,len/2],后缀中是否有重复子串,若是的话表... 阅读全文
posted @ 2017-04-18 22:59 pengwill 阅读(153) 评论(0) 推荐(0)
摘要:UVA.10986 Fractions Again (经典暴力)题意分析同样只枚举1个,根据条件算出另外一个。代码总览#include #include #include #include #include #include #include #include #include #i... 阅读全文
posted @ 2017-04-18 22:52 pengwill 阅读(87) 评论(0) 推荐(0)
摘要:UVA.10305 Maximum Product (暴力)题意分析直接枚举起点和重点,然后算出来存到数组里面,sort然后取最大值即可。代码总览#include #include #include #include #include #include #include #inclu... 阅读全文
posted @ 2017-04-18 22:47 pengwill 阅读(90) 评论(0) 推荐(0)
摘要:UVA.725 Division (暴力)题意分析找出abcdefghij分别是0-9(不得有重复),使得式子abcde/fghij = n。 如果分别枚举每个数字,就会有10^10,肯定爆炸,由于分数值已知,其实发现可以通过枚举分母,来计算出分子,然后再看看这些数字是否符合题意即可... 阅读全文
posted @ 2017-04-18 22:45 pengwill 阅读(120) 评论(0) 推荐(0)
摘要:HDU.3342 Legal or Not (拓扑排序 TopSort)题意分析裸的拓扑排序 根据是否成环来判断是否合法 详解请移步 算法学习 拓扑排序(TopSort) 代码总览#include #include #include #include #include #incl... 阅读全文
posted @ 2017-04-04 18:28 pengwill 阅读(102) 评论(0) 推荐(0)
摘要:HDU.2647 Reward(拓扑排序 TopSort)题意分析裸的拓扑排序 详解请移步 算法学习 拓扑排序(TopSort) 这道题有一点变化是要求计算最后的金钱数。最少金钱值是888,最少的差额是1,如1号的人比2号钱要多,2号至少是1号人的钱数+1.根据拓扑排序的思想,我们... 阅读全文
posted @ 2017-04-04 18:21 pengwill 阅读(140) 评论(0) 推荐(0)
摘要:HDU.1285 确定比赛名次 (拓扑排序 TopSort)题意分析裸的拓扑排序 详解请移步 算法学习 拓扑排序(TopSort) 只不过这道的额外要求是,输出字典序最小的那组解。那么解决方案就是每次扫描1-n节点的入度,并且只取出1个编号最小的节点,处理他然后继续取,直到所有节点... 阅读全文
posted @ 2017-04-04 18:14 pengwill 阅读(163) 评论(0) 推荐(0)
摘要:UVA.10305 Ordering Tasks题意分析详解请移步 算法学习 拓扑排序(TopSort)拓扑排序的裸题 基本方法是,indegree表示入度表,vector存后继节点。在topsort函数中,制造一个辅助队列,首先从入度表中找到入度为0的点作起点,并且置入度为-1。... 阅读全文
posted @ 2017-04-03 14:42 pengwill 阅读(117) 评论(0) 推荐(0)
摘要:拓扑排序一、基本概念在一个有向无环图(Directed Acyclic Graph, DAG)中,规定 表示一条由u指向v的的有向边。要求对所有的节点排序,使得每一条有向边 中u都排在v的前面。 换个形象点的解释,我们在学习一门课程之前,应该需要一定的预备知识,比如在学习B课程之... 阅读全文
posted @ 2017-04-03 14:39 pengwill 阅读(461) 评论(0) 推荐(0)

点击右上角即可分享
微信分享提示