Tr A Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2977 Accepted Submission(s): 2217 Problem Description A为一个方阵,则Tr A表示A的迹(就是主对角线上各项的和),现要求Tr(A^k)%9973. Input 数据的第一行是一个T,表示有T组数据. 每组数据的第一…
UVA 11551 - Experienced Endeavour 题目链接 题意:给定一列数,每一个数相应一个变换.变换为原先数列一些位置相加起来的和,问r次变换后的序列是多少 思路:矩阵高速幂,要加的位置值为1.其余位置为0构造出矩阵,进行高速幂就可以 代码: #include <cstdio> #include <cstring> const int N = 55; int t, n, r, a[N]; struct mat { int v[N][N]; mat() {mem…
Cellular Automaton Time Limit: 12000MS Memory Limit: 65536K Total Submissions: 3048 Accepted: 1227 Case Time Limit: 2000MS Description A cellular automaton is a collection of cells on a grid of specified shape that evolves through a number of dis…
矩阵高速幂: 依据关系够建矩阵 , 高速幂解决. Arc of Dream Time Limit: 2000/2000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others) Total Submission(s): 2164 Accepted Submission(s): 680 Problem Description An Arc of Dream is a curve defined by following fun…
MF( i ) = a ^ fib( i-1 ) * b ^ fib ( i ) ( i>=3) mod 1000000007 是质数 , 依据费马小定理 a^phi( p ) = 1 ( mod p ) 这里 p 为质数 且 a 比 p小 所以 a^( p - 1 ) = 1 ( mod p ) 所以对非常大的指数能够化简 a ^ k % p == a ^ ( k %(p-1) ) % p 用矩阵高速幂求fib数后代入就可以 M斐波那契数列 Time Limit: 3000/100…
题目连接:uva 11885 - Number of Battlefields 题目大意:给出周长p,问多少种形状的周长为p的,而且该图形的最小包围矩阵的周长也是p,不包含矩形. 解题思路:矩阵高速幂.假设包括矩形的话,相应的则是斐波那契数列的偶数项,所以相应减去矩形的个数就可以. #include <cstdio> #include <cstring> using namespace std; typedef long long ll; const ll MOD = 987654…
How many ways? ? Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2046 Accepted Submission(s): 758 Problem Description 春天到了, HDU校园里开满了花, 姹紫嫣红, 很漂亮. 葱头是个爱花的人, 看着校花校草竞相开放, 漫步校园, 心情也变得舒畅. 为了多看看这…
CRB and Puzzle Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 483 Accepted Submission(s): 198 Problem Description CRB is now playing Jigsaw Puzzle. There are kinds of pieces with infinite…