- 博客(17)
- 资源 (1)
- 收藏
- 关注
转载 二分图匈牙利算法最大匹配及相关
二分图:简单来说,如果图中点可以被分为两组,并且使得所有边都跨越组的边界,则这就是一个二分图。准确地说:把一个图的顶点划分为两个不相交集 U 和 V ,使得每一条边都分别连接U 、 V 中的顶点。如果存在这样的划分,则此图为一个二分图。二分图的一个等价定义是:不含有「含奇数条边的环」的图。图 1 是一个二分图。为了清晰,我们以后都把它画成图 2 的形式。 匹配:在图论中,一个「匹配」
2016-05-23 19:09:16
684
原创 素数筛法
hdu 2.1.3 Largest prime factor Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5996 Accepted Submission(s): 1834 Proble
2016-04-26 23:20:40
500
转载 快速幂
Rightmost Digit 问题描述 : Given a positive integer N, you should output the most right digit of N^N. 输入: The input contains several test cases. The first line of the input is a single integ
2016-04-16 22:05:07
442
原创 归并排序求逆序对
求逆序对方法有两种: 树状数组和归并排序,还有暴力 暴力就是两个for循环判断当ia[j],则ans++; 这里先说归并排序吧,在另一篇博客中再讲树状数组求逆序对(实际上是我写树状数组的还有bug没找到.......) #include #include #include #include using namespace std; const int N = 100005; int a[N
2016-04-14 12:54:23
323
原创 神奇的进制转换(模板)
(10进制转换为其他进制): #include int main() { int m,n; char a[100]; while(~scanf("%d%d",&n,&m)) { int i, t=1; if(n<0) {n=-n;t=0;} for( i=0;n!=0;i++) {
2016-04-08 13:09:16
414
原创 最小公倍数公约数(gcd函数)(模板)
hrbust 1882 链接:http://acm.hrbust.edu.cn/index.php?m=ProblemSet&a=showProblem&problem_id=1882 三原色 Time Limit: 1000 MS Memory Limit: 32768 K Total Submit: 783(298 users)
2016-04-08 12:59:35
1304
原创 dfs模板
直接上模板吧,自己复习用: #include #include #include #incldue using namespace std; #define N 10000+5 char map[N][N]; bool visit[N][N]; int cnt=0; int n, m; int dx[4]={1, 0, -1, 0}; int dy[4]={0, 1, 0, -1}; int d
2016-03-31 22:09:22
478
原创 分形 递归打印之神奇三角形
上次做过几乎一样的题,然而到校赛上就懵逼了.特发此博客,以此哀悼 题意是打印三角形,且最后无空格 上代码: #include #include #include #include #include using namespace std; #define MAX 3010 char maps[MAX][MAX]; void print(int n, int x, int y) {
2016-03-28 22:26:43
3650
原创 bfs模板
bfs模板: #include #include #include #include #include #include using namespace std; #define N 1000+5 int map[N][N]; bool visit[N][N]; //标记访问 int n, m; int dx[4]={1, 0, -1, 0}; int dy[4]={0, 1, 0, -1
2016-03-26 23:04:18
319
转载 bfs题目小结
转载请注明出处,谢谢 http://blog.youkuaiyun.com/ACM_cxlove?viewmode=contents by---cxlove 刚好yobobobo最近做BFS,我也被渲染了,当是复习一下,也总结一下吧,大部分是HDOJ上的BFS题目,由于本人时间有限,会持续更新 HDU 1548 http://acm.hdu.edu.cn/sho
2016-03-26 22:57:10
399
原创 并查集模板
自己习惯这么写, 复习用: #include #include #include #include #include using namespace std; #define N 1005 int fa[N]; void init(int n){ for(int i=0; i<n; i++){ fa[i]=i; } } int find(int u){
2016-03-22 22:46:20
288
原创 kmp模板
我的习惯写法, 自己复习用: #include #include #define N 1005 char a[N], b[N]; int d1, d2; int next[N]; void Get_next(){ int i, j; i=1, j=0; next[1]=0; while(j<d2){ if(j==0||b[i]==b[j]){
2016-03-22 22:25:26
334
转载 博弈论小结
组合游戏总结——基本博弈问题 【概述】 最近的几次比赛,博弈的题目一直不少,而且博弈问题是一块比较复杂、庞大的内容,因此在这里小结一下,希望能够帮自己理清一些思路,争取也多来几个系列,呵呵。 竞赛中出现的组合游戏问题一般都满足以下特征: 1.二人博弈游戏,每个人都采用对自己最有利的策略,并且是两个人轮流做出决策 2.在游戏中的任意时刻,每个玩家可选择的状态是固定的,没
2016-03-15 20:10:00
1194
转载 并查集
作者:CYJB 出处:http://www.cnblogs.com/cyjb/ GitHub:https://github.com/CYJB/ 本文大部分为转载,因本人觉得写的好,借鉴一下。 并查集 并查集(Union-find Sets)是一种非常精巧而实用的数据结构,它主要用于处理一些不相交集合的合并问题。一些常见的用途有求连通子图、求最小生成树的 Kruskal 算法和求最
2016-03-13 17:13:08
361
原创 分形 递归打印之C5
Help C5 Time Limit: 1000 MS Memory Limit: 65535 K Total Submit: 113(29 users) Total Accepted: 35(28 users) Rating: Special Judge: No Description Hello,
2016-03-11 16:53:44
785
转载 全排列函数
这是一个求一个排序的下一个排列的函数,可以遍历全排列,要包含头文件 下面是以前的笔记 与之完全相反的函数还有prev_permutation (1) int 类型的next_permutation int main() { int a[3]; a[0]=1;a[1]=2;a[2]=3; do { cout } while (next_permutati
2016-03-01 21:15:50
995
原创 fibonacci数列 取模
问题描述 Fibonacci数列的递推公式为:Fn=Fn-1+Fn-2,其中F1=F2=1。 当n比较大时,Fn也非常大,现在我们想知道,Fn除以10007的余数是多少。 输入格式 输入包含一个整数n。 输出格式 输出一行,包含一个整数,表示Fn除以10007的余数。 说明:在本题中,答案是要求Fn除以10007的余数,因此我们只要能算出这个余
2016-02-06 00:15:23
897
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人