06 2014 档案
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2027
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1280 普通方法(625ms) #include <stdio.h> #include <string.h> #include <stdlib.h> int b[3000*1501]; int cmp(const
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1480
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1232 不知道为么,这样就WA if(findx(x)!=findx(y)) merge(x,y); http://acm.hdu.edu.cn/showproblem.php?pid=1213
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1250 大数斐波那契 %08d是什么东西,为什么我用flag交不上,唉,不刷大数了,没劲。暑假再讲。 就是交不上 http://acm.sdut.edu.cn/sdutoj/problem.php?action=s
阅读全文
摘要:因为0<=N<=10000,所以可以让存在数组里的每一位直接乘i; 我也不会,借鉴了大神的代码。 只能 t=ta[j]*i+k; 不能t=ta[j]*i; k=ta[j]%10; ta[j+1]=ta[j+1]+k; 这样就不是ta[i+1]*i了,结果就被变大了
阅读全文
摘要:一直格式错误,不想改了,没A
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2094 1 #include 2 #include 3 #include 4 int n; 5 int map[2001][2001],d[2001],v[2001]; 6 char name[2001][1...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1285拓扑排序:次序问题AOV网:用顶点表示活动,弧表示活动间的优先关系的有向图,AOV网中不应该出现有向环:如果存在环,则某项活动以自己为先决条件。 1 #include 2 #include 3 #incl...
阅读全文
摘要:本来以为这题能用并查集做的,但一想不对例如A-> B,A->C如果用并查集的话B与C就不能连了,但实际B可以是C的徒弟,所以这题是考拓扑排序。#include#includeint d[105],map[105][105],vis[105];int main(){ int i,j,k,f,n,...
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1690 坑爹的题,必须用__int64 %I64d(以前没用过) 因为这题的数据特别大,所以用-1
阅读全文
摘要:通过做这题,发现了自己的问题很大,做题不是贴代码,而是要了解思想;这题考的是有一个起点的集合,求起点集合到一个终点的最短距离, 本来想用Floy的但一看map[1000][1000]超时,有向图,逆序建邻接矩阵,这样就成了一个终点到所有点的最短路了。
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2112 本题题目意思非常简单,麻烦的就是处理一下字符串,这是我能力欠缺的地方 #include<stdio.h>#include<iostream>#include<string.h>#define maxint
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1596
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1874 SPFA Floy
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2544 DJ
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2894 就因为粗心,一中午没A,题目说是2000000条边无向图,我数组却开了2000000真是该死,我一看别人A的状态,内存都比我大一倍,瞬间知道自己手残
阅读全文
摘要:SPFA算法 SPFA(Shortest Path Faster Algorithm)是Bellman-Ford算法的一种队列实现,减少了不必要的冗余计算。 算法大致流程是用一个队列来进行维护。 初始时将源加入队列。 每次从队列中取出一个元素,并对所有与他相邻的点进行松弛,若某个相邻的点松弛成功,则
阅读全文
摘要:尼玛 我今天刚刚知道什么是负权回路 任意相连的无向图之间都是回路!!! 囧了一天了,算是看出来了,渣比 A B 则A能到B且B能到A,这就是一个回路。
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1879
阅读全文
摘要:这题竟然出错在了快排上,对double类型的数据排序, return a>b?1:-1; 如果还是减的话则会造成数据丢失 http://acm.hdu.edu.cn/showproblem.php?pid=1875
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1372 以前真二,模板题 OJ真奇怪,有时能A有时W,
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2896 最小生成树:n个顶点n-1条边 本题因为有50000个点,所以只能用Kuscal
阅读全文
摘要:http://acm.sdut.edu.cn/sdutoj/showproblem.php?pid=2144&cid=1186 最小生成树,最重要的是了解思想 稠密图用Prim,稀疏图用Kruskal K(每次找最小的边连接,一条边连接两个点,所以单路就可以了) Prim() #include <s
阅读全文
摘要:我以为像a、aa这样的输入应该是没有输出的,结果还是要输出aa。 建树的时候就是常规建树,不过查找的时候要做一些变形:对于一个单词,从第一位检查有没有单词是它的前缀,如果有的话,再去检查它的后半部分是不是一个独立的单词,要满足这两次查找才能输出。 题意:给一些单词(以字典序输入),找出那些可以分成另
阅读全文
摘要:#include #include #include #include using namespace std; typedef struct Node { struct Node *next[10]; int flag; } Node,*Tree; int flag1; void Creat(Tree &T) { T=(Node *)malloc(sizeof(...
阅读全文
摘要:这题看是否 这题能A是侥幸,解决的办法是先存一下输入的字符串,进行排序。 Problem Description An encoding of a set of symbols is said to be immediately decodable if no code for one symbol
阅读全文
摘要:这题就是一个字典树的模板题 统计难题 Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131070/65535 K (Java/Others) Total Submission(s): 16997 Accepted Submission(s)
阅读全文
摘要:大意:输入几个字符串,然后再输入几个字符串,看第一次输入的字符串有多少没有在后面的字符串中出现(后输入的字符串不一定出现在之前的字符串中) #include <stdio.h> #include <string.h> #include <stdlib.h> typedef struct Node {
阅读全文
摘要:一改时间以后WA了,我就知道这题是考字典树,可惜代码怎么也不会敲了,郁闷。 #include <stdio.h>#include <string.h>#include <stdlib.h>typedef struct Node{ int flag; struct Node *next[26]; }N
阅读全文
摘要:数论公式(x*y) mod z=x*(y mod z)modz.
阅读全文
摘要:明明很简单,我却错了N++遍,主要原因是在于自己,给自己测试数据时,忘了测大数据,因为只保留小数点后两位,而200以后的数都是0.69.#include #include #include #include using namespace std;int main(){ double a[10...
阅读全文
摘要:1.打表 打表,是一个信息学专用术语,意指对某种找规律等题目,直接输出答案。这种算法也在对某种题目没有最优解法时,用来得到分数的一种策略。 打表一般分为两步:找到答案与输出答案。 找到答案的方式 一、通过找规律,找出对于每个输入数据n,f[n]的最终结果。 常见题目有费波纳契数列等; 二、通过暴力搜
阅读全文
摘要:#include <iostream>#include <stdio.h>#include <string.h>#include <stdlib.h>using namespace std;char a[1010],b[1010];int ta[1010],tb[1010];int main(){
阅读全文
摘要:公式递推代码C(n, m) = C(n -1, m - 1) + C(n - 1, m)计算组合数的公式是:c(m,n)=m!/(n!*(m-n)!)利用杨辉三角来解决组合数可以避免数据超范围!!!第二届山东省省赛D Binomial Coeffcients#include #include #in...
阅读全文
摘要:A(Phone Number) 1.字典树 2.暴力 #include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <algorithm> using namespace std; in
阅读全文
摘要:求最大公约数和最小公倍数假设有两个数a和b,求a,b的最大公约数和最小公倍数实际上是一个问题,得出这两个数的最大公约数就可以算出它们的最小公倍数。最小公倍数的公式是 a*b/mm为最大公约数因为a=m*i; b=m*j;最小公倍数为 m*i*j那么,下面就开始计算a和b的最大公约数。更相损减法:《九...
阅读全文
摘要:题意: 有一个公司由于某个病毒使公司赢亏数据丢失,但该公司每月的 赢亏是一个定数,要么一个月赢利s,要么一月亏d。现在ACM只知道该公司每五个月有一个赢亏报表,而且每次报表赢利情况都为亏。在一年中这样的报表总共有8次(1到5,2到6,…,8到12),现在要编一个程序确定当赢s和亏d给出,并满足每张报
阅读全文
摘要:水题,我却坑了好多时间,。。。
阅读全文
摘要:主要是思维,dis[s][t]数组的作用
阅读全文
摘要:[题目大意]:给定一个字符串,求到哪一位时的字串是前几位循环组成的,并求出循环次数。 思路:求每个前缀的最小循环周:从i到n枚举len,如果len%(len-next[len])==0,则这个前缀是由循环节组成的,且循环次数为len/(len-next[len])//len为当前i的值,next[l
阅读全文
摘要:#include <stdio.h>#include <string.h>#include <stdlib.h>char a[1000001];int next[1000001];int l;void Getnext(){ int j=-1; int i=0; next[0]=-1;//忘写了,死循
阅读全文
摘要:#include <stdio.h>#include <string.h>#include <stdlib.h>char a[1000001],b[1000001];int next[1000001];int l,l2;void Getnext(){ int i=0; int j=-1; next[
阅读全文
摘要:当然,对于Spfa判负环,实际上还有优化:就是把判断单个点的入队次数大于n改为:如果总的点入队次数大于所有点两倍 时有负环,或者单个点的入队次数大于sqrt(点数)有负环。这样时间复杂度就降了很多了。 判断给定的有向图中是否存在负环。 利用 spfa 算法判断负环有两种方法: 1) spfa 的 d
阅读全文
摘要:#include#include#includeint k,h[110],mark;struct M{ int data; struct M *next;}*head[110];void init(){ int i; for(i = 0; i next = NULL; ...
阅读全文
摘要:#include#includeint d[15],map[15][15],vis[15];int main(){ int i,j,k,f,n,m,u,v; while(~scanf("%d%d",&n,&m)) { memset(d,0,sizeof(d)); memset(map,0,sizeo...
阅读全文
摘要:Flip Game 思想很不成熟, #include <stdio.h>#include <string.h>#include <stdlib.h>int map[4][4];int ans=100; int f(){ for(int i=0;i<4;i++) { for(int j=0;j<4;j
阅读全文
摘要:#include <iostream>#include <stdio.h>#include <string.h>#include <stdlib.h>using namespace std;int n,m;int bin[50001];int findx(int x){ int r=x; while
阅读全文
摘要:比较抽象吧,看到题时一点思想也没有,参考了别人的代码才知道。。。渣渣 #include <iostream>#include <stdio.h>#include <string.h>#include <stdlib.h>using namespace std;int map[10][10];int
阅读全文
摘要:#include <stdio.h>#include <string.h>int map[51][51][51];int v[51][51][51];int a,b,c,t11;struct node{ int x,y,z,ans;}q[200001];int jx[6]={0,0,0,0,-1,1
阅读全文
摘要:dfs #include <stdio.h> #include <string.h> char Map[16][16]; int mv[16][16]; //mv[i][j] == 0 没有被访问 //mv[i][j] == 1 已经被访问 struct N { int x,y; } ; int j
阅读全文
摘要:http://poj.org/problem?id=3259 Description While exploring his many farms, Farmer John has discovered a number of amazing wormholes. A wormhole is ver
阅读全文
摘要:BF是对边进行操作,DJ是对点进行操作。N个顶点的最短路是N-1条边,所以循环N-1次。 学的好吃力。。。自己好渣渣。。。不愧是渣渣二号,还是贴贴思想吧 1,.初始化:将除源点外的所有顶点的最短距离估计值 d[v] ←+∞, d[s] ←0; 2.迭代求解:反复对边集E中的每条边进行松弛操作,使得顶
阅读全文
摘要:http://poj.org/problem?id=1611 Description Severe acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, was recognized as a g
阅读全文
摘要:被坑了3个小时,本来以为算法错了,谁知道,竟然是素数筛弄错了 !!! #include <iostream>#include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>using namespace std;int
阅读全文
摘要:http://poj.org/problem?id=3278 Catch That Cow Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 47010 Accepted: 14766 Description Farmer John
阅读全文