摘要:经典题目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][...
阅读全文
摘要:经典题目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...
阅读全文
摘要:Matrix67大牛关于矩阵经典题目的链接:http://www.matrix67.com/blog/archives/276/nyoj 298 点的变换题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=298经典题目1 给定n个点,m个操...
阅读全文
摘要:矩阵的快速幂是用来高效地计算矩阵的高次方的。将朴素的o(n)的时间复杂度,降到log(n)。这里先对原理(主要运用了矩阵乘法的结合律)做下简单形象的介绍:一般一个矩阵的n次方,我们会通过连乘n-1次来得到它的n次幂。但做下简单的改进就能减少连乘的次数,方法如下:把n个矩阵进行两两分组,比如:A*A*...
阅读全文
摘要: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...
阅读全文
摘要: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...
阅读全文
摘要:Description两只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面。它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到碰面为止。可是它们出发之前忘记了一件很重要的事情,既没有问清楚对方的特征,也没有约定见面的具体位置。不过青蛙们都是很乐观的,它们觉得只要一直朝着某个...
阅读全文
摘要:欧几里德算法欧几里德算法又称辗转相除法,用于计算两个整数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...
阅读全文
摘要: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...
阅读全文
摘要: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 ...
阅读全文
摘要:Description"Good man never makes girls wait or breaks an appointment!" said the mandarin duck father. Softly touching his little ducks' head, he told ...
阅读全文
摘要:DescriptionFarmer John's cousin, Farmer Ron, who lives in the mountains of Colorado, has recently taught his cows to ski. Unfortunately, his cows are ...
阅读全文
摘要: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 ...
阅读全文
摘要:ZQUOJ 22354&&&POJ 2407 RelativesDescriptionGivenn, a positive integer, how many positive integers less thannare relatively prime ton? Two integersaand...
阅读全文
摘要:DescriptionA number of schools are connected to a computer network. Agreements have been developed among those schools: each school maintains a list o...
阅读全文
摘要: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...
阅读全文
摘要:DescriptionWe will use the following (standard) definitions from graph theory. LetVbe a nonempty and finite set, its elements being called vertices (o...
阅读全文
摘要: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...
阅读全文
摘要:题目:Sightseeing来源:ZQUOJ 21463&&POJ 3463DescriptionTour operator Your Personal Holiday organises guided bus trips across the Benelux. Every day the bus ...
阅读全文
摘要:题目:COURSES 来源:ZQUOJ 23124&&POJ 1469DescriptionConsider a group of N students and P courses. Each student visits zero, one or more than one courses. Yo...
阅读全文