上一页 1 2 3 4 5 6 7 ··· 14 下一页
摘要: 摘要: 本文主要讲述了二分搜索算法的基本思想和实现原理,着重讲解了二分搜索法在编程竞赛中的一些典型应用。 基本思想 实现原理 典型应用 例题解析 基本思想 二分搜索法的基本思想是通过不断的缩小解可能存在的范围,从而求得问题最优解的方法。比如一个直观的问题是在一个由小到大的数列a中找到一个数ai,使得 阅读全文
posted @ 2018-09-11 20:57 Reqaw 阅读(405) 评论(0) 推荐(1) 编辑
摘要: HDU 5912 Fraction 给出系数计算一个迭代的公式,反向代入即可。 1 #include <cstring> 2 #include <cstdio> 3 #include <algorithm> 4 using namespace std; 5 6 const int maxn = 10 阅读全文
posted @ 2018-08-20 18:29 Reqaw 阅读(153) 评论(0) 推荐(0) 编辑
摘要: HDU 2089 不要62 数据量比较小,还是直接暴力吧。 1 #include<stdio.h> 2 int a[1000010]; 3 int F(int m); 4 int main() 5 { 6 int i,sum,n,m; 7 for(i=1;i<=1000000;i++) 8 a[i] 阅读全文
posted @ 2018-08-20 18:00 Reqaw 阅读(202) 评论(0) 推荐(0) 编辑
摘要: 摘要 本文主要讲解贪心法的基本思想和实现,怎么运用贪心法,着重讲解在编程竞赛中的一些典型应用。 什么是贪心法? 在编程竞赛中的典型应用有哪些? 例题解析 什么是贪心法? 贪心法本质上讲不是一种真正的算法,而是一种思想,就是解决问题的时候遵循着某种规则,不断贪心地选取当前最优策略,以达到结果最优的目的 阅读全文
posted @ 2018-08-16 19:06 Reqaw 阅读(1898) 评论(0) 推荐(0) 编辑
摘要: 摘要: 本文主要讲述了AC自动机的基本思想和实现原理,如何构造AC自动机,着重讲解AC自动机在算法竞赛中的一些典型应用。 什么是AC自动机? 如何构造一个AC自动机? AC自动机在算法竞赛中的典型应用有哪些? 例题解析 什么是AC自动机? 什么是AC自动机,不是自动AC的机器(想的美),而是一种多模 阅读全文
posted @ 2018-08-11 19:08 Reqaw 阅读(3516) 评论(1) 推荐(3) 编辑
摘要: 题目链接: https://vjudge.net/problem/ZOJ-1456 These are N cities in Spring country. Between each pair of cities there may be one transportation track or n 阅读全文
posted @ 2018-08-06 14:35 Reqaw 阅读(236) 评论(0) 推荐(0) 编辑
摘要: 题目链接: https://vjudge.net/problem/POJ-3268 One cow from each of N farms (1 ≤ N ≤ 1000) conveniently numbered 1..N is going to attend the big cow party 阅读全文
posted @ 2018-08-06 12:04 Reqaw 阅读(227) 评论(0) 推荐(0) 编辑
摘要: 摘要: 本文主要讲解了Trie的基本思想和原理,实现了几种常见的Trie构造方法,着重讲解Trie在编程竞赛中的一些典型应用。 什么是Trie? 如何构建一个Trie? Trie在编程竞赛中的典型应用有些? 例题解析 什么是Trie? 术语取自retrieval中(检索,收回,挽回)的trie,读作 阅读全文
posted @ 2018-08-04 08:34 Reqaw 阅读(1649) 评论(0) 推荐(1) 编辑
摘要: 题目链接: https://cn.vjudge.net/problem/POJ-3037 Bessie and the rest of Farmer John's cows are taking a trip this winter to go skiing. One day Bessie find 阅读全文
posted @ 2018-07-28 19:25 Reqaw 阅读(290) 评论(0) 推荐(0) 编辑
摘要: 题目链接: https://cn.vjudge.net/problem/POJ-1724 N cities named with numbers 1 ... N are connected with one-way roads. Each road has two parameters associ 阅读全文
posted @ 2018-07-28 19:07 Reqaw 阅读(343) 评论(0) 推荐(0) 编辑
摘要: 题目链接: https://cn.vjudge.net/problem/POJ-1860 Several currency exchange points are working in our city. Let us suppose that each point specializes in t 阅读全文
posted @ 2018-07-28 19:02 Reqaw 阅读(404) 评论(0) 推荐(0) 编辑
摘要: 摘要:本文主要讲解在竞赛中如何求解图中存在环的最短路问题。其中涉及的算法有Floyd算法,Dijkstra算法,使用邻接表和优先队列优化的Dijkstra算法,Bellman-Ford算法,简要总结各算法的基本思想和实现以及使用注意事项。 最短路问题主要分为单源最短路问题和多源最短路问题。给出顶点数 阅读全文
posted @ 2018-07-25 20:31 Reqaw 阅读(3601) 评论(2) 推荐(0) 编辑
摘要: 题目链接:https://cn.vjudge.net/problem/HDU-1079 题目: Adam and Eve enter this year’s ACM International Collegiate Programming Contest. Last night, they play 阅读全文
posted @ 2018-07-24 20:33 Reqaw 阅读(228) 评论(0) 推荐(0) 编辑
摘要: 题目链接: https://cn.vjudge.net/problem/HDU-3613 After an uphill battle, General Li won a great victory. Now the head of state decide to reward him with h 阅读全文
posted @ 2018-07-23 17:32 Reqaw 阅读(296) 评论(0) 推荐(0) 编辑
摘要: 拓展KMP解决的问题是给两个串S和T,长度分别是n和m,求S的每一个后缀子串与T的最长公共前缀分别是多少,记作extend数组,也就是说extend[i]表示S[i,n-1](i从0开始)和T的最长公共前缀长度。 需要注意的是如果extend[i]=m,即S[i,n-1]和T的最长公共前缀长度是m( 阅读全文
posted @ 2018-07-23 16:42 Reqaw 阅读(1066) 评论(0) 推荐(2) 编辑
摘要: 题目链接: https://cn.vjudge.net/problem/HDU-3613 After an uphill battle, General Li won a great victory. Now the head of state decide to reward him with h 阅读全文
posted @ 2018-07-23 08:51 Reqaw 阅读(247) 评论(0) 推荐(0) 编辑
摘要: KMP算法是一种改进的模式匹配算法,相比于朴素的模式匹配算法效率更高。下面讲解KMP算法的基本思想与实现。 先来看一下朴素模式匹配算法的基本思想与实现。 朴素模式匹配算法的基本思想是匹配过程中如果该位置相等,继续匹配各自的下一位,直至匹配完成,或者出现一位不匹配,如果该位置不相等,主串的匹配位置返回 阅读全文
posted @ 2018-07-21 15:52 Reqaw 阅读(1844) 评论(0) 推荐(0) 编辑
摘要: 式子a≡b(mod n)称为a和b关于模n同余,它的充要条件是a-b是n的整数倍,即a-b=zn(其中z取整数)。 而模线性方程组ax≡b(mod n)可以写成ax-b=zn(其中z取整数),移项可得 ax-zn=b,也即二元一次方程ax+by=c的形式,利用拓展欧几里得算法(extgcd)可以求解 阅读全文
posted @ 2018-07-20 20:28 Reqaw 阅读(1266) 评论(0) 推荐(0) 编辑
摘要: 题目链接: BZOJ: https://www.lydsy.com/JudgeOnline/problem.php?id=1477 POJ: https://cn.vjudge.net/problem/POJ-1061 题目描述: Description 两只青蛙在网上相识了,它们聊得很开心,于是觉 阅读全文
posted @ 2018-07-20 20:25 Reqaw 阅读(327) 评论(0) 推荐(0) 编辑
摘要: 题目链接: https://cn.vjudge.net/problem/POJ-1730 题目描述: We say that x is a perfect square if, for some integer b, x = b 2. Similarly, x is a perfect cube i 阅读全文
posted @ 2018-07-19 20:12 Reqaw 阅读(215) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 14 下一页