上一页 1 ··· 16 17 18 19 20 21 22 23 24 ··· 38 下一页
摘要: 简单的一题,使用类DIJK的算法就可以了。#include #include #include #include using namespace std;struct Edge{ int u,v; double lose; int next;}edge[2500050];int head[50010... 阅读全文
posted @ 2014-11-01 11:39 chenjunjie1994 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 题目要求两点间的最大值作为距离即:即是切比雪夫距离。而切比雪夫距离与曼哈顿距离的转换却很巧妙。把平面坐标所有点绕原点逆向旋转45度后,所得点的曼哈顿距离之和除以√2,即是切雪比夫距离。旋转点的公式是提取无理数,即每个新坐标可以是(x-y,x+y)。计算其曼哈顿距离后除以2即可。#include #i... 阅读全文
posted @ 2014-10-29 16:22 chenjunjie1994 阅读(217) 评论(0) 推荐(0) 编辑
摘要: 求的是曼哈顿距离。可以把X,Y的距离分开来求。其中,求X、Y的距离可以通过排序后递推的方式求出值的。#include #include #include #include #define LL __int64using namespace std;struct point{ int x,y; int... 阅读全文
posted @ 2014-10-29 15:30 chenjunjie1994 阅读(103) 评论(0) 推荐(0) 编辑
摘要: 贪心,注意排序条件。#include #include #include using namespace std;const int N=25;struct En{ int DSP,HP;}E[N];bool cmp(En a,En b){ if(a.DSP*1.0/a.HP>b.DSP*1.0/b... 阅读全文
posted @ 2014-10-27 18:37 chenjunjie1994 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 最大流建图。开始以为旧桥有1000座,没敢用枚举,后来看看题目发现了只是十二座。枚举桥的状态没问题。对于隧道的容量W,可以虚拟出第三个结点表示,如u->v。增加一个点p,u->p(INF),p->v(INF),p->End(W);#include #include #include #include... 阅读全文
posted @ 2014-10-25 21:35 chenjunjie1994 阅读(165) 评论(0) 推荐(0) 编辑
摘要: 纯BFS+优先队列扩展。 #include #include #include #include #include using namespace std; bool vis[5100]; char str[5100]; struct point{ int x,y; int cos... 阅读全文
posted @ 2014-10-25 19:38 chenjunjie1994 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 感觉是有很多细节要处理的。尤其是求逆元后的运算,应该是存在超范围的情况的。#include #include #include #include #include #include #define MOD 10007#define N 305using namespace std;struct po... 阅读全文
posted @ 2014-10-25 10:53 chenjunjie1994 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 说实话,挺复杂的一道题。我采用栈的方式,DFS在搜索完一个节点的所有子结点后,通过排序,加快计算该结点所有可能的路径:子结点与子结点的连通,子结点与父结点的连通,通过父结点与各祖先结点的连通。同时记录路径数计算。思路清晰就能写出来了。#include #include #include #inclu... 阅读全文
posted @ 2014-10-24 18:49 chenjunjie1994 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 开始时设的是第一、二行前i,j列有k种的方法数,但是,这根本转移不了--!难点在于1,2行的讨论啊。。。设f[i][j][0]为前i列分成j个部分,且第i列的两个为同一部分的方法数.f[i][j][1]为前i列分成j个部分,且第i列的两个为不同部分的方法数。于是,很容易就会转到递推方程 了。f[i+... 阅读全文
posted @ 2014-10-23 19:30 chenjunjie1994 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 维护两个优先队列即可。要注意,当出现蛋糕的位置刚好在狗的位置时,存在右边。注意输出大小写。。。#include #include #include using namespace std;struct RP{ int pos; bool operator t.pos) return true; r... 阅读全文
posted @ 2014-10-23 16:21 chenjunjie1994 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 扩展KMP很容易就明白过来了。注意的是,后面明文的长度要少于密文,而且当前K+Extend[k]>=L输出时犯了很多次二,后来人注意吧。#include #include #include #include using namespace std;char t[30];char table[30];... 阅读全文
posted @ 2014-10-22 23:51 chenjunjie1994 阅读(111) 评论(0) 推荐(0) 编辑
摘要: 和上题一样,但K较大,不能直接用矩阵来写。这个矩阵必定是这个形式的。0 1 1 11 0 1 11 1 0 11 1 1 0分成对角线上元素B与非对角线上元素Ak: 1 2 3 4 ...A: 1 2 7 20...B: 0 3 6 21...按上题经验,我们可以知道,B才是要求的。那么Bn=(k-... 阅读全文
posted @ 2014-10-19 11:40 chenjunjie1994 阅读(204) 评论(0) 推荐(0) 编辑
摘要: 思路挺清晰的。不过,我就是WA。不清楚为什么,很多数据都过了。其实,一个置换后若有循环节个数为K,则N必定可以除以尽K。而K正好可以看成一个环。为什么呢?看前K个珠子,就是一个环,而后面的若干个K个珠子,不过就是不停的重复而已。这样,循环节的个数可以由最大公约数求得。那么,这个K个珠子构成的环符合题... 阅读全文
posted @ 2014-10-19 10:51 chenjunjie1994 阅读(310) 评论(0) 推荐(0) 编辑
摘要: 水题一道,不加优化也能0MS#include #include #include #include #include using namespace std;int gcd(int a,int b){ if(b==0) return a; return gcd(b,a%b);}int Power(i... 阅读全文
posted @ 2014-10-17 11:30 chenjunjie1994 阅读(138) 评论(0) 推荐(0) 编辑
摘要: 这题的时间卡的。。。。必须用欧拉来优化,而且要加素数表。最重要是,因为最后结果要/n,而数据很大,所以,必须在之前就先/n了,否则会爆数据。#include #include #include #include #include #define LL __int64using namespace s... 阅读全文
posted @ 2014-10-17 11:17 chenjunjie1994 阅读(201) 评论(0) 推荐(0) 编辑
上一页 1 ··· 16 17 18 19 20 21 22 23 24 ··· 38 下一页