
竞赛算法
文章平均质量分 76
竞赛算法
ClownFeilong
这个作者很懒,什么都没留下…
展开
-
ACM搜索算法总结
转自:http://blog.youkuaiyun.com/shenmen123456/article/details/6695499 在此感谢~搜索是ACM竞赛中的常见算法,本文的主要内容就是分析它的 特点,以及在实际问题中如何合理的选择搜索方法,提高效率。文章的第一部分首先分析了各种基本的搜索及其各自的特点。第二部分在基本搜索方法...转载 2018-03-18 20:26:25 · 1775 阅读 · 0 评论 -
图的基本算法
原文:https://www.jianshu.com/p/70952b51f0c8 图是一种灵活的数据结构,一般作为一种模型用来定义对象之间的关系或联系。对象由顶点(V)表示,而对象之间的关系或者关联则通过图的边(E)来表示。图可以分为有向图和无向图,一般用G=(V,E)来表示图。经常用邻接矩阵或者邻接表来描述一副图。在图的基本算法中,最初需要接触的就是图的遍历算法,...转载 2018-03-18 20:24:04 · 1872 阅读 · 0 评论 -
DFS和BFS搜索
原文:http://blog.youkuaiyun.com/u011437229/article/details/53188837DFS 算法思想:一直往深处走,直到找到解或者走不下去为止BFS算法DFS:使用栈保存未被检测的结点,结点按照深度优先的次序被访问并依次被压入栈中,并以相反的次序出栈进行新的检测。BFS:使用队列保存未被检测的结点。结点按照宽度优先的次序被访问和进出队列。框架:BFS:#inc转载 2018-03-18 20:21:19 · 245 阅读 · 0 评论 -
ACM-搜索
原文地址:http://blog.youkuaiyun.com/ljtlyy/article/details/51235198dfs(深搜)深搜,简言之就是不撞南墙不回头顾名思义,深度优先搜索所遵循的策略就是尽可能“深”的在图中进行搜索,对于图中某一个顶点V,如果它还有相邻的顶点(在有向图中就是还有以V为起点的边)且未被访问,则访问此顶点。如果找不到,则返回到上一个顶点。这一过程一直进行直到所有的...转载 2018-03-18 20:09:25 · 337 阅读 · 0 评论 -
HDU 6129 lucas判断组合数奇偶性
Just do itTime Limit: 5000/2500 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 1106 Accepted Submission(s): 641Problem DescriptionThere is a non原创 2017-08-17 10:15:23 · 440 阅读 · 0 评论 -
多校第四场 1003 HDU 6069 素数晒应用
[cpp] view plain copyprint?#include #include #include #include #include #include #include #include #include #include #include typedef long long LL; const int maxsize = 1e6+转载 2017-08-03 20:10:03 · 365 阅读 · 0 评论 -
HDU 3038 How Many Answers Are Wrong 带权并查集 dfs过程中维护变量
How Many Answers Are WrongTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 9169 Accepted Submission(s): 3335Problem Description原创 2017-08-02 17:25:57 · 423 阅读 · 0 评论 -
多校第三场 1005 HDU 6060 思维贪心+dfs+一维建树
RXD and dividingTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 1353 Accepted Submission(s): 244Problem DescriptionRXD has原创 2017-08-02 14:08:01 · 408 阅读 · 0 评论 -
POJ3020-Antenna Placement 无向二分图 匈牙利算法 裸题
The Global Aerial Research Centre has been allotted the task of building the fifth generation of mobile phone nets in Sweden. The most striking reason why they got the job, is their discovery of a new原创 2017-07-30 12:00:25 · 760 阅读 · 0 评论 -
POJ 2226 Muddy Fields 二分图巧妙建图 + 二分图最大匹配
Rain has pummeled the cows' field, a rectangular grid of R rows and C columns (1 <= R <= 50, 1 <= C <= 50). While good for the grass, the rain makes some patches of bare earth quite muddy. The cows, b原创 2017-07-30 10:29:45 · 402 阅读 · 0 评论 -
POJ 1486 Sorting Slides 二分图关键边 匈牙利算法
Professor Clumsey is going to give an important talk this afternoon. Unfortunately, he is not a very tidy person and has put all his transparencies on one big heap. Before giving the talk, he has to s原创 2017-07-30 09:42:47 · 439 阅读 · 0 评论 -
POJ-2060-Taxi Cab Scheme 二分图匈牙利算法 裸题
Running a taxi station is not all that simple. Apart from the obvious demand for a centralised coordination of the cabs in order to pick up the customers calling to get a cab as soon as possible,there原创 2017-07-30 09:39:30 · 470 阅读 · 0 评论 -
Treasure Exploration (POJ_2594) 可重复用点的最大匹配 FLOYD+dfs匈牙利
Have you ever read any book about treasure exploration? Have you ever see any film about treasure exploration? Have you ever explored treasure? If you never have such experiences, you would never know原创 2017-07-30 09:36:28 · 317 阅读 · 0 评论 -
POJ_3150_矩阵快速幂+循环矩阵的乘法
//开始没有主要矩阵实际上是循环的,所以用n^3的算法一直简单优化,比如把中//最后层,移动到中间//但,实际上不论E还是自己构造出来的F都是循环的,比如E单位矩阵,实际上就是1的位置发生了移动而已//循环矩阵和循环矩阵相乘之后还是循环矩阵//而训换矩阵实际上只要求出第一行,后面的实际上可以通过D[i][j] = D[i-1][(j-1+n)%n]来算出矩阵矩阵快速幂//中间遇到了一转载 2017-07-24 15:02:19 · 395 阅读 · 0 评论 -
POJ 2115 C Looooops extend gcd +找点
A Compiler Mystery: We are given a C-language style for loop of type for (variable = A; variable != B; variable += C) statement;I.e., a loop which starts by setting variable to value A and wh原创 2017-07-24 14:35:37 · 333 阅读 · 0 评论 -
poj 3101 Astronomy 分数lcm+大数java
import java.lang.reflect.Array;import java.math.BigInteger;import java.util.ArrayList;import java.util.Scanner;public class Main { static private ArrayList Array0 = new ArrayList(); static pri原创 2017-07-24 14:32:41 · 359 阅读 · 0 评论 -
POJ 1061 青蛙的约会 extend GCD +找点
两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面。它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到碰面为止。可是它们出发之前忘记了一件很重要的事情,既没有问清楚对方的特征,也没有约定见面的具体位置。不过青蛙们都是很乐观的,它们觉得只要一直朝着某个方向跳下去,总能碰到对方的。但是除非这两只青蛙在同一时间跳到同一点上,不然是永远都不可能碰面的。为了帮助这两只乐观的青蛙,原创 2017-07-24 14:20:07 · 318 阅读 · 0 评论 -
51Nod-1186-质数检测 V2 JAVA biginteger包
输入已经是大数 C++需要高精度 这里用JAVA 简单一点 直接操作。import java.math.BigInteger;import java.util.Scanner;public class Main { public static void main(String[] args) { // TODO Auto-generated method stub原创 2017-07-24 14:10:43 · 389 阅读 · 0 评论 -
51nod oj 1035 最长的循环节 简单数论
正整数k的倒数1/k,写为10进制的小数如果为无限循环小数,则存在一个循环节,求<=n的数中,倒数循环节长度最长的那个数,假如存在多个最优的答案,输出所有答案中最大的那个数。1/6= 0.1(6) 循环节长度为11/7= 0.(142857) 循环节长度为61/9= 0.(1) 循环节长度为1Input输入n(10 Output输出Sample I原创 2017-07-24 14:08:18 · 564 阅读 · 0 评论 -
51Nod 1352 集合计数 extend GCD 扩展欧几里得+找点
给出N个固定集合{1,N},{2,N-1},{3,N-2},...,{N-1,2},{N,1}.求出有多少个集合满足:第一个元素是A的倍数且第二个元素是B的倍数。提示:对于第二组测试数据,集合分别是:{1,10},{2,9},{3,8},{4,7},{5,6},{6,5},{7,4},{8,3},{9,2},{10,1}.满足条件的是第2个和第8个。Input第1行:1个整数T原创 2017-07-24 14:00:42 · 384 阅读 · 0 评论 -
POJ2891 Strange Way to Express Integers 同余式的合并操作(中国剩余定理两两不一定非素的替代)
Elina is reading a book written by Rujia Liu, which introduces a strange way to express non-negative integers. The way is described as following:Choose k different positive integers a1, a2, …, ak.原创 2017-07-24 12:13:13 · 432 阅读 · 0 评论 -
51nod 1116 K进制下的大数 利用同余式的乘法传递性质
有一个字符串S,记录了一个大数,但不知这个大数是多少进制的,只知道这个数在K进制下是K - 1的倍数。现在由你来求出这个最小的进制K。例如:给出的数是A1A,有A则最少也是11进制,然后发现A1A在22进制下等于4872,4872 mod 21 = 0,并且22是最小的,因此输出k = 22(大数的表示中A对应10,Z对应35)。Input输入大数对应的字符串S。S的长度小于10^原创 2017-07-24 12:08:28 · 324 阅读 · 0 评论 -
HDU 2594 next[len]应用
J - Simpsons’ Hidden Talents 应用next[len],注意一个最大长度min(lena,lenb)。#include#include#include#include#include#include#includeusing namespace std;const int maxlen = 100010原创 2017-07-20 11:27:19 · 412 阅读 · 0 评论 -
HDU3336 next数组性质
K - Count the string It is well known that AekdyCoin is good at string problems as well as number theory problems. When given a string s, we can write down all the non-empty prefixes of this str原创 2017-07-20 11:21:12 · 338 阅读 · 0 评论 -
POJ 3026 BFS+PRIM 地图上迷宫最小生成树
#include#include#include#include#include#include#include#include#include#include#define MAXAMOUNT 110using namespace std;char Map[100][100];int x, y;int n;int ans;int start[2];int p原创 2017-07-15 15:27:08 · 572 阅读 · 0 评论 -
poj 1679 最小生成树唯一性判断(KRUSKAL)
记录结果边集 每次删除一个再进行 最小树操作#include#include#include#include#includeusing namespace std;const int maxn = 107;int pre[maxn];//并查集的父节点数组int Rank[maxn];//通过秩合并的数组int n, m;int t;typedef stru原创 2017-07-15 15:24:57 · 479 阅读 · 0 评论 -
CF #419 div2
哇 这次上了波分 开心这次的题目,作为弱弱的我,感觉A题还是可以的,用到模拟A:A. Karen and Morningtime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputs原创 2017-06-18 11:00:23 · 398 阅读 · 0 评论