随笔分类 - ACM_ac算法与函数
摘要:网上发现了不错的博客讲解... 熊猫的板子:http://blog.csdn.net/qq_32734731/article/details/51484729 组合数的预处理(费马小定理|杨辉三角|卢卡斯定理):http://www.indestinee.com/combinationinit/ 求
阅读全文
摘要:学习链接: http://blog.csdn.net/v_july_v/article/details/7041827 代码:
阅读全文
摘要:学习链接: http://www.cppblog.com/mythit/archive/2009/04/21/80633.html http://blog.csdn.net/niushuai666/article/details/7002736 http://www.cnblogs.com/kuan
阅读全文
摘要:1 void search(int cur) 2 { 3 if(cur==n) 4 tot++; 5 else{ 6 for(int i=0; i<n; i++){ 7 if(!vis[0][i]&&!vis[1][cur+i]&&!vis[2][cur-i+n]){ 8 C[...
阅读全文
摘要:Problem You are given an N x N matrix with 0 and 1 values. You can swap any two adjacent rows of the matrix. Your goal is to have all the 1 values in
阅读全文
摘要:查找数字规律公式的网站: http://oeis.org/A005773 C++头文件: #include <bits/stdc++> 链接: http://blog.kuoe0.tw/posts/2014/01/31/install-gnu-gcc-on-os-x-and-use-the-head
阅读全文
摘要:旋转卡壳:http://www.cnblogs.com/Booble/archive/2011/04/03/2004865.html 代码:
阅读全文
摘要:描述 公元3000年,子虚帝国统领着N个星系,原先它们是靠近光束飞船来进行旅行的,近来,X博士发明了星际之门,它利用虫洞技术,一条虫洞可以连通任意的两个星系,使人们不必再待待便可立刻到达目的地。 帝国皇帝认为这种发明很给力,决定用星际之门把自己统治的各个星系连结在一起。 可以证明,修建N-1条虫洞就
阅读全文
摘要:晚上学习了一些图论相关算法: 单源最短路径算法: Bellman-Ford 算法: Bellman-Ford 算法是一种用于计算带权有向图中单源最短路径(SSSP:Single-Source Shortest Path)的算法。该算法由 Richard Bellman 和 Lester Ford 分
阅读全文
摘要:1 vector<int> p[MAX]; 2 int V; 3 int color[MAX]; 4 5 bool dfs(int v,int c) 6 { 7 color[v]=c; 8 for(int i=0; i<p[v].size(); i++){ 9 if(color[p[v][i]==c
阅读全文
摘要:自从2006年3月10日至11日的首届数独世界锦标赛以后,数独这项游戏越来越受到人们的喜爱和重视。据说,在2008北京奥运会上,会将数独列为一个单独的项目进行比赛,冠军将有可能获得的一份巨大的奖品———HDU免费七日游外加lcy亲笔签名以及同hdu acm team合影留念的机会。所以全球人民前仆后
阅读全文
摘要:map的使用方法: 1 #include <cstdio> 2 #include <map> 3 #include <string> 4 using namespace std; 5 6 int main() 7 { 8 //声明int为键,const char* 为值 9 map<int,cons
阅读全文
摘要:set是维护集合的容器 1 #include <cstdio> 2 #include <set> 3 using namespace std; 4 5 int main() 6 { 7 //声明 8 set<int> s; 9 10 //插入元素 11 s.insert(1); 12 s.inser
阅读全文
摘要:复杂度 O(logn) 1 #include <queue> 2 #include <cstdio> 3 using namespace std; 4 5 //表示节点的结构体 6 struct node{ 7 int val; 8 node *lch,*rch; 9 }; 10 11 //插入数值
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2612 BFS搜索 目标地 并记录下来 之后再判断两段路程之和 代码: 1 #include <stdio.h> 2 #include <string.h> 3 #include <math.h> 4 #
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1584 全部状态都判断一遍 代码: 1 #include <stdio.h> 2 #include <string.h> 3 #include <math.h> 4 #include <algorithm
阅读全文
摘要:输入: N=4,L=25,P=10 A={10,14,20,21} B={10,5,2,4} 输出: 2 (在第1个和第2个加油站加油) 1.如果优先队列也是空的,则无法到达终点. 2.否则取出优先队列中的最大元素,并用来给卡车加油. 1 int L,P,N; 2 int A[MAX],B[MAX]
阅读全文
摘要:堆的两种操作所花的时间都和树的深度成正比.因此,如果一共有n个元素,那么每个操作可以在O(logn)时间内完成. 堆的实现 1.左儿子的编号是自己的编号*2+1 2.右儿子的编号是自己的编号*2+1 push和pop的实现: 1 int heap[MAX],sz=0; 2 3 void push(i
阅读全文
摘要:输入: n=4 m=3 M=10000 输出: 4 (1+1+2=1+3=2+2=4) 复杂度(nm) 1 int n,m; 2 int a[MAX]; 3 4 int dp[MAX][MAX]; //数组 5 6 void solve() 7 { 8 dp[0][0]=1; 9 for(int i
阅读全文

浙公网安备 33010602011771号