- 博客(519)
- 资源 (83)
- 收藏
- 关注
原创 POJ 3233
矩阵的快速幂模m#include #include #include using namespace std;const int MAXN = 110;struct Matrax{ int m[MAXN][MAXN];};Matrax a, per;int n, m;void Inite(){ int i, j; for(i = 0; i < n; ++i
2014-01-01 20:16:08 600
原创 zoj 1508 Intervals
#include #include #include #include using namespace std;const int INF = 10000000;const int MAXN = 50010;struct ArcNode{ int to; int weight; ArcNode* pNext; ArcNode() { to = 0; wei
2013-12-31 23:58:42 700
原创 zoj 2770 Burn the Linked Camp
Bellman_Ford实现:点击打开http://blog.csdn.net/hearthougan/article/details/17631941差分约束系统的SPFA实现:SPFA速度比Bellman_Ford快多了。链表实现,表头不存数据。#include #include #include #include using namespace std;const in
2013-12-30 20:48:02 977
原创 zoj 2770
#include #include #include using namespace std;const int MAXN = 1010;const int MAXM = 23000;const int INF = 100000000;struct Edge{ int u, v, w;}edges[MAXM];int n;int EN;int dist[MA
2013-12-28 14:38:09 1237
原创 poj 1201
#include #include #include using namespace std;const int MAXN = 50010;const int INF = 100000000;struct Edge{ int u, v, w;}edges[MAXN];int dist[MAXN];int n, l, r;void Inite(){
2013-12-28 14:36:16 767
原创 Floyd Test
算法思想: Floyd(弗洛伊德)算法的基本思想是:对一个顶点个数为n的有向网(或无向网),设置一个n×n的方阵A(k) ,其中除对角线的矩阵元素都等于0外,其他元素A(k) [i][j] (i≠j)表示从顶点vi到顶点vj的有向路径长度,k表示运算步骤,k = -1, 0, 1, 2, …, n-1。初始时:A (-1)= Edge(图的邻接矩阵),即初始时,以
2013-12-26 21:50:19 701
原创 poj 3259 Wormholes
http://poj.org/problem?id=3259判断是否存在负权回路,如果存在,则表明某个顶点i入队列的次数超过了n次,n是顶点的数目。#include #include #include #include #include using namespace std;const int MAXN = 550;const int INF = 10000000;
2013-12-25 18:01:49 648
原创 poj 3268
点击打开题目#include #include #include #include using namespace std;const int INF = 10000000;const int MAXN = 1010;struct ArcNode//邻接表结构{ int to; int weight; ArcNode* pNext; Ar
2013-12-25 15:02:04 756
原创 SPFA
算法思想: Bellman-Ford算法的时间复杂度比较高,为O(n3)或O(nm),原因在于Bellman-Ford算法要递推n次,每次递推,扫描所有的边,在递推n次的过程中很多判断是多余的。SPFA算法(Shortest Path Faster Algorithm)是Bellman-Ford算法的一种队列实现,减少了不必要的冗余判断。 SPFA算法的大致流程是用一个队列来进
2013-12-25 14:54:22 986
原创 poj 1556 The Doors
#include #include #include #include #include using namespace std;const int INF = 100000000;const int MAXN = 100;struct Point{ double x; double y;};struct Edge{ int u; i
2013-12-22 14:59:39 848
原创 poj 2240 zoj1092 Arbitrage
#include #include #include using namespace std;const int MAXN = 35;const int MAXM = 1000;struct exchange{ int ci, cj; double cij;}Ex[MAXM];char name[MAXN][20], a[20], b[20];doubl
2013-12-21 19:27:00 743
原创 hdu 3579 Hello Kiki
题目:点击打开题目#include #include #include using namespace std;typedef long long LL;const int MAXN = 10;LL Gcd(LL a, LL b){ return b == 0 ? a : Gcd(b, a%b);}void Ex_Gcd(LL a, LL b, LL &d,
2013-12-20 14:35:37 789
原创 hdu 1573 X问题
#include #include #include using namespace std;const int MAXN = 15;typedef long long LL;LL Gcd(LL a, LL b){ if(b == 0) return a; else return Gcd(b, a%b);}void Ex_
2013-12-20 12:09:21 768
原创 poj 2115 C Looooops
#include #include #include using namespace std;typedef long long LL;void Ex_Gcd(LL a, LL b, LL &d, LL &x, LL &y){ if(b == 0) { x = 1; y = 0; d = a; ret
2013-12-18 21:22:20 732
原创 poj 2891 Strange Way to Express Integers
#include #include #include using namespace std;void Ex_Gcd(long long a, long long b, long long &d, long long &x, long long &y){ if(b == 0) { x = 1; y = 0; d = a;
2013-12-12 21:15:03 764
原创 同余问题怎么求解最小正整数解
一:若gcd(a, b) = 1,则方程ax ≡ c (mod b)在[0, b-1]上有唯一解。证明: 存在性:存在整数k和l使a*k + b*l = gcd(a, b) = 1,即我们可以求出ax ≡ 1 (mod b)的解x0。当然,两边乘以c有a(cx0) ≡ c (mod b),所以有x = cx0就是ax ≡ c (mod b)的解。由于加上或减去若干倍b都是该方程的解...
2013-12-12 19:23:46 4017
原创 nefu 84
#include using namespace std;long long Extended_Gcd(long long a, long long b, long long &x, long long &y){ if(b == 0) { x = 1; y = 0; return a; } long long
2013-12-10 17:58:46 705
原创 hdu 2035 人见人爱A^B
设:a%m = r1, b % m = r2, 则:(a*b) % m = (a%m)*(b%m)%m;令: a = k1 *m + r1, b = k2 * m + r2;则:a*b = ( k1*m+r1 ) * (k2*m + r2) = (k1*k2*m^2 + k1*m*r2 + k2*m*r1 + r1*r2)=> (a*b)%m = (k1*k2*m^2 + k1*m
2013-12-10 13:52:51 1355
原创 hdu 1021 Fibonacci Again
设a%m = r1, b%m = r2,则:(a+b)%m = (r1 + r2)%m = (a%m + b%m)%m;令:a = k1 * m + r1; b = k2 * m + r2;则:(a+b)%m = (k1*m + r1 + k2 * m + r2)%m = ((k1 + k2) * m + r1 + r2)%m = (r1 + r2)%m = (a%m + b%m)%m
2013-12-10 13:33:09 772
原创 poj 2769
同余问题:#include #include #include using namespace std;const int MAXN = 310;int main(){ bool p[100010]; int arr[MAXN]; int T; cin>>T; while(T--) { int n;
2013-12-10 13:04:49 863
原创 hdu 2534 Score
我们知道Gcd(a, b) = a*x + b*y;其中x, y 为正整数,如果当Gcd(a, b) = 1 时,a与b互素。根据这个,可以解这一题目a*x+b*y为a和b所能组成的数,x, y非负整数。设K为a,b所不能组成的最大数,而m和n为大于K的两个连续数,且m > n;x1,y1分别为组成m所需要a,b的个数,同理x2,y2为组成n所需a, b的个数。则有:a*x2 + b*y2
2013-12-09 19:35:38 914
原创 hdu 1007
点击打开资料#include #include #include #include #include #include using namespace std;const int MAXN = 100100;struct Point{ double x, y;};Point point[MAXN];Point s[MAXN];int cmp(Point a,
2013-12-06 10:20:23 639
转载 最近点对 分治算法分析
问题描述 在应用中,常用诸如点、圆等简单的几何对象代表现实世界中的实体。在涉及这些几何对象的问题中,常需要了解其邻域中其他几何对象的信息。例如,在空中交通控制问题中,若将飞机作为空间中移动的一个点来看待,则具有最大碰撞危险的2架飞机,就是这个空间中最接近的一对点。这类问题是计算几何学中研究的基本问题之一。下面我们着重考虑平面上的最接近点对问题。 最接近点对问题的提法是:
2013-12-05 18:29:32 1480
原创 hdu 1432 Lining Up
题目大意:给你一些顶点,计算出最多有多少顶点在一条直线上。思路:共线向量内积为零。#include #include using namespace std;const int MAXN = 750;int main(){ int n; int i, j, k; int x[MAXN], y[MAXN]; while (cin>>n
2013-12-05 14:47:29 954
原创 poj 1122 FDNY to the Rescue!
关键是建图,zoj也有一题,不过格式要求不一样,数据好像也不一样,卡那儿了!下面是能过poj的代码:#include #include #include #include using namespace std;const int MAXN = 25;const int INF = 10000010;struct Dist{ bool station; int n
2013-12-05 14:10:05 918
原创 zoj 2750 Idiomatic Phrases Game
题目大意: 成语接龙游戏,给定一些成语,该组成语中第1个和最后一个必须是给定的两个成语。在这组成语中,前一个成语的最后一个汉字必须和后一个成语的第一个汉字相同。在游戏过程中,Tom有一本字典,他必须从字典中选用成语。字典中每个成语都有一个权值T,表示选用这个成语后,Tom需要花时间T才能找到下一个合适的成语。你的任务是编写程序,给定字典,计算Tom至少需要花多长时间才能找到一个满足条件的
2013-12-04 18:18:30 851
原创 kmp hdu 3336
#include <iostream>#include <cstring>#include <cstdio>using namespace std;const int MAXN = 200010;int next[MAXN];void Get_Next(char* str, int n){ int i = 0, j = -1; ...
2013-12-03 18:25:43 641 1
原创 poj 1961 Period KMP
题目大意:给定字符串S,求其前n位所组成的字符串,其最小单元重复的次数。是上一篇的拓展;上一篇 #include <iostream>#include <cstring>#include <cstdio>using namespace std;const int MAXN = 1000010;int next[MAXN];...
2013-12-03 15:32:06 718
原创 KMP poj 2406 Power Strings 字符串的幂
题意: 给定两个字符串a和b,定义式子:a*b表示两个字符串的连接,例如:a = "abc", b = "def" 则:a*b = "abcdef"。如果将连乘看成乘法,则按照普遍的方法一个非负整数的幂表示如下: a^0 = "" (the empty string) and a^(n+1) = a*(a^n).输入: 输入字符串S每组样例一行,S为可打印字符.S长度在1~...
2013-12-03 13:25:12 1120
原创 KMP poj 2752 Seek the Name, Seek the Fame
深入理解KMP中的next,当我们求完next之后,len为字符串S的长度, 令j = next[len],k = next[j],则有:S[j-k+1, j] = S[len-k+1, len],就是根据这个思路来求解这个问题; #include <iostream>#include <cstring>#include <cstdio&...
2013-12-03 12:33:11 698
原创 KMP poj 3461
找一个模式串在主串中出现的次数 #include <iostream>#include <cstring>using namespace std;const int MAXN = 1000010;const int MAXM = 10010;int nextval[MAXM];void Get_NextVal(char* str){...
2013-12-03 11:30:46 659
原创 BUAACM 晴天小猪是点赞狂魔
简单题,并且数据还有问题!#include #include #include using namespace std;int main(){ int T; long long i, n; cin>>T; while (T--) { cin>>n; long long a; long long t = (n+1) * n / 2; long long k
2013-11-30 16:29:24 1269
原创 ZOJ1298, POJ1135 Domino Effect
题目大意: 你的任务是编写程序,给定多米诺骨牌游戏,计算最后倒下的是哪一张骨牌、在什么时间倒下。这些多米诺骨牌游戏包含一些“关键牌”,他们之间由一行普通骨牌连接。当一张关键牌倒下时,连接这张关键牌的所有行都开始倒下。当倒下的行到达其他还没倒下的关键骨牌时,则这些关键骨牌也开始倒下,同样也使得连接到它的所有行开始倒下。每一行骨牌可以从两个端点中的任何一张关键牌开始倒下,甚至两个端点
2013-11-29 21:36:53 825
原创 Dijkstra 算法介绍以及实现
Dijkstra算法的具体实现方法为:1. 设置两个顶点的集合T和S:a) S中存放已找到最短路径的顶点,初始时,集合S中只有一个顶点,即源点v0;b) T中存放当前还未找到最短路径的顶点;2.在T集合中选取当前长度最短的一条最短路径(v0,…,vk),从而将vk加入到顶点集合S中,并修改源点v0到T中各顶点的最短路径长度;重复这一步骤,直到所有的顶点都加入到集
2013-11-29 20:15:18 1541
原创 zoj 2048 Highways poj 1751
两题几乎就是一摸一样的,只是输入格式不一样。#include #include #include #include #include #include using namespace std;const int MAX = 1000;const int INF = 10000010;struct Point{ int x,y;} point[MAX];in
2013-11-28 13:04:42 967
原创 zoj 1914 poj 2349 Arctic Network
题目大意: 国防部想在北部的前哨之间建立一个无线网络连接这些前哨。在建立网络时使用了两种不同的通信技术:每个前哨有一个无线电收发器,有一些前哨还有一个卫星频道。 任何两个拥有卫星频道的前哨之间可以直接通过卫星进行通信,而且卫星通信跟距离和位置无关。否则,两个前哨之间通过无线电收发器进行通信,并且这两个前哨之间的距离不能超过D,这个D值取决于无线电收发器的功率。功率越大,D值也就
2013-11-28 11:24:31 717
原创 hdu 2089 不要62
#include #include #include using namespace std;int dp[10][3];int DP(int x){ bool flag = false; int s[15]; int idx = 0, sum = x, ans = 0; for(; x; x /= 10) s[++idx] = x % 10; s[idx+1] =
2013-11-27 21:50:02 664
原创 zoj 2158 poj 1789 Truck History (Prim)
题目大意: 高级货物运输公司ACM使用不同类型的卡车。有些卡车用来运蔬菜,有些用来运水果,还有一些用来运砖,等等。该公司对不同的卡车有自己的编码方法。卡车的编码为一个包含7个字符的字符串(每个位置上的字符都有特定的含义,但这一点对本题并不重要)。在ACM公司发展历史上的初期,只有一种卡车可供使用,只有一种卡车类型编码;后来又引进了新的一种卡车类型,新卡车的类型编码是从第一种卡车编码派
2013-11-27 19:56:53 867
原创 zoj 1586 QS Network (Prim)
#include #include using namespace std;const int MAXN = 1010;const int INF = 10000010;int Edge[MAXN][MAXN];int lowcost[MAXN];int adapter[MAXN];int n;void Inite(){ int i, j; cin>>n; me
2013-11-27 18:40:52 791
原创 Prim算法
一、Prim 算法的思想: 普里姆算法的基本思想是以顶点为主导地位:从起始顶点出发,通过选择当前可用的最小权值边依次把其他顶点加入到生成树当中来。设连通无向网为G(V, E),在普里姆算法中,将顶点集合V分成两个子集合T和T':T:当前生成树顶点集合,T':不属于当前生成树的顶点集合。很显然有:T∪T'= V。普里姆算法的具体过程为:1) 从连通无向网G中选择一
2013-11-27 05:07:57 2132
从Word Embedding到Bert模型—自然语言处理中的预训练技术发展史
2018-11-19
word2vec系列资料
2018-11-19
word2vec 中的数学原理详解
2018-11-01
CRF++0.58-Linux+Windows
2018-09-29
npp++32位+NPPTextFx.dll
2018-09-27
李航-《统计学习方法》高清完整版(带书签)
2018-09-17
Stanford NLP note - Christopher Manning教授-完整吧
2018-08-08
Stanford NLP note - Christopher Manning教授
2018-08-08
21天学通Java-第7版-超清带书签.pdf
2018-07-27
计算机统计自然语言处理PDF
2018-07-26
Tensorflow 实战Google深度学习框架-清晰-带书签
2018-01-17
TensorFlow Machine Learning Cookbook.pdf
2018-01-17
最大熵模型与自然语言处理
2017-09-01
cudnn 5.1 for CUDA 8.0 Linux
2017-07-05
李宏毅 一天搞懂深度学习.ppt版下载
2017-02-23
机器学习实战(中文带书签+英文+源代码)
2016-10-26
《机器学习》----[Tom M. Mitchell]--带书签
2016-10-16
《统计学习方法》李航-带书签高清完整PDF版
2016-10-16
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人