随笔分类 -  ACM算法

上一页 1 2 3 4 5 下一页

矩阵十题(3)
摘要:经典题目3 POJ3233 题目大意:给定矩阵A,求A + A^2 + A^3 + ... + A^k的结果(两个矩阵相加就是对应位置分别相加)。输出的数据mod m。k 2 #include 3 #define N 31 4 struct Matrix 5 { 6 int a[N][... 阅读全文

posted @ 2013-05-16 18:51 jumpingfrog0 阅读(2405) 评论(1) 推荐(0)

矩阵十题(2)
摘要:经典题目2 给定矩阵A,请快速计算出A^n(n个A相乘)的结果,输出的每个数都mod p。 由于矩阵乘法具有结合律,因此A^4 = A * A * A * A = (A*A) * (A*A) = A^2 * A^2。我们可以得到这样的结论:当n为偶数时,A^n = A^(n/2) * A^(n... 阅读全文

posted @ 2013-05-16 11:36 jumpingfrog0 阅读(576) 评论(0) 推荐(0)

矩阵十题(1)
摘要:Matrix67大牛关于矩阵经典题目的链接:http://www.matrix67.com/blog/archives/276/nyoj 298 点的变换题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=298经典题目1 给定n个点,m个操... 阅读全文

posted @ 2013-05-15 20:25 jumpingfrog0 阅读(820) 评论(0) 推荐(1)

矩阵快速幂
摘要:矩阵的快速幂是用来高效地计算矩阵的高次方的。将朴素的o(n)的时间复杂度,降到log(n)。这里先对原理(主要运用了矩阵乘法的结合律)做下简单形象的介绍:一般一个矩阵的n次方,我们会通过连乘n-1次来得到它的n次幂。但做下简单的改进就能减少连乘的次数,方法如下:把n个矩阵进行两两分组,比如:A*A*... 阅读全文

posted @ 2013-05-15 17:18 jumpingfrog0 阅读(754) 评论(0) 推荐(0)

AC自动机 HDU 2222 Keywords Search
摘要:Problem DescriptionIn the modern time, Search engine came into the life of everybody like Google, Baidu, etc.Wiskey also wants to bring this feature t... 阅读全文

posted @ 2012-10-27 15:56 jumpingfrog0 阅读(246) 评论(0) 推荐(0)

线段树单点更新 HDU 1394 Minimum Inversion Number
摘要:Problem DescriptionThe inversion number of a given number sequence a1, a2, ..., an is the number of pairs (ai, aj) that satisfy i aj.For a given sequ... 阅读全文

posted @ 2012-09-01 19:02 jumpingfrog0 阅读(389) 评论(0) 推荐(0)

扩展欧几里德 ZQUOJ 21001&&POJ 1061 青蛙的约会
摘要:Description两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面。它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到碰面为止。可是它们出发之前忘记了一件很重要的事情,既没有问清楚对方的特征,也没有约定见面的具体位置。不过青蛙们都是很乐观的,它们觉得只要一直朝着某个... 阅读全文

posted @ 2012-08-20 23:21 jumpingfrog0 阅读(1099) 评论(2) 推荐(0)

欧几里德与扩展欧几里德算法
摘要:欧几里德算法欧几里德算法又称辗转相除法,用于计算两个整数a,b的最大公约数。基本算法:设a=qb+r,其中a,b,q,r都是整数,则gcd(a,b)=gcd(b,r),即gcd(a,b)=gcd(b,a%b)。第一种证明: a可以表示成a = kb + r,则r = a mod b 假设d是a... 阅读全文

posted @ 2012-08-19 00:47 jumpingfrog0 阅读(64199) 评论(9) 推荐(46)

差分约束系统 ZQUOJ 23147&&POJ 1201 Intervals
摘要:DescriptionYou are given n closed, integer intervals [ai, bi] and n integers c1, ..., cn.Write a program that:reads the number of intervals, their end... 阅读全文

posted @ 2012-08-17 18:11 jumpingfrog0 阅读(383) 评论(0) 推荐(0)

差分约束系统 ZQUOJ 21452&&POJ 1364 King
摘要:DescriptionOnce, in one kingdom, there was a queen and that queen was expecting a baby. The queen prayed: "If my child was a son and if only he was a ... 阅读全文

posted @ 2012-08-17 00:51 jumpingfrog0 阅读(266) 评论(0) 推荐(0)

k短路 POJ 2449 Remmarguts' Date
摘要:Description"Good man never makes girls wait or breaks an appointment!" said the mandarin duck father. Softly touching his little ducks' head, he told ... 阅读全文

posted @ 2012-08-16 17:10 jumpingfrog0 阅读(301) 评论(0) 推荐(0)

强连通分量 POJ 2375 Cow Ski Area
摘要:DescriptionFarmer John's cousin, Farmer Ron, who lives in the mountains of Colorado, has recently taught his cows to ski. Unfortunately, his cows are ... 阅读全文

posted @ 2012-08-14 14:36 jumpingfrog0 阅读(338) 评论(0) 推荐(0)

欧拉函数 原根 POJ 1284 Primitive Roots
摘要:Primitive RootsDescriptionWe say that integer x, 0 2 int main() 3 { 4 int p,rea,i; 5 while(scanf("%d",&p)!=EOF) 6 { 7 p--; 8 ... 阅读全文

posted @ 2012-08-13 14:20 jumpingfrog0 阅读(325) 评论(0) 推荐(0)

欧拉函数 POJ 2407 Relatives&&POJ 2478 Farey Sequence
摘要:ZQUOJ 22354&&&POJ 2407 RelativesDescriptionGivenn, a positive integer, how many positive integers less thannare relatively prime ton? Two integersaand... 阅读全文

posted @ 2012-08-11 22:20 jumpingfrog0 阅读(372) 评论(0) 推荐(0)

强连通分量 ZQUOJ 10203&&POJ 1236 Network of Schools
摘要:DescriptionA number of schools are connected to a computer network. Agreements have been developed among those schools: each school maintains a list o... 阅读全文

posted @ 2012-08-10 21:41 jumpingfrog0 阅读(204) 评论(0) 推荐(0)

欧拉回路 ZQUOJ21349&&POJ2337 Catenyms
摘要:DescriptionA catenym is a pair of words separated by a period such that the last letter of the first word is the same as thefirst letter of the second... 阅读全文

posted @ 2012-08-09 15:32 jumpingfrog0 阅读(513) 评论(0) 推荐(1)

强连通分量 ZQUOJ 21467&&POJ 2553 The Bottom of a Graph
摘要:DescriptionWe will use the following (standard) definitions from graph theory. LetVbe a nonempty and finite set, its elements being called vertices (o... 阅读全文

posted @ 2012-08-07 16:25 jumpingfrog0 阅读(300) 评论(0) 推荐(0)

最大二分匹配 ZQUOJ21474 && POJ1486 Sorting Slides
摘要:DescriptionProfessor Clumsey is going to give an important talk this afternoon. Unfortunately, he is not a very tidy person and has put all his transp... 阅读全文

posted @ 2012-08-05 16:12 jumpingfrog0 阅读(212) 评论(0) 推荐(0)

dijkstra ZQUOJ 21463&&POJ 3463 Sightseeing
摘要:题目:Sightseeing来源:ZQUOJ 21463&&POJ 3463DescriptionTour operator Your Personal Holiday organises guided bus trips across the Benelux. Every day the bus ... 阅读全文

posted @ 2012-08-01 17:26 jumpingfrog0 阅读(215) 评论(0) 推荐(0)

最大二分匹配 匈牙利算法模板&&POJ 1469 COURSES
摘要:题目:COURSES 来源:ZQUOJ 23124&&POJ 1469DescriptionConsider a group of N students and P courses. Each student visits zero, one or more than one courses. Yo... 阅读全文

posted @ 2012-07-28 04:08 jumpingfrog0 阅读(210) 评论(0) 推荐(0)

上一页 1 2 3 4 5 下一页

导航