任意门:http://poj.org/problem?id=3233 Matrix Power Series Time Limit: 3000MS   Memory Limit: 131072K Total Submissions: 28619   Accepted: 11646 Description Given a n × n matrix A and a positive integer k, find the sum S = A + A2 + A3 + … + Ak. Input The…
One day, Alice and Bob felt bored again, Bob knows Alice is a girl who loves math and is just learning something about matrix, so he decided to make a crazy problem for her. Bob has a six-faced dice which has numbers 0, 1, 2, 3, 4 and 5 on each face.…
Power of Matrix Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit Status Practice UVA 11149 Appoint description:  System Crawler  (2015-03-15) Description   Problem B : Power of Matrix Time limit: 10 seconds Consider an n-…
Description In our daily life we often use 233 to express our feelings. Actually, we may say 2333, 23333, or 233333 ... in the same meaning. And here is the question: Suppose we have a matrix called 233 matrix. In the first line, it would be 233, 233…
题意: 给出一个\(n \times k\)的矩阵\(A\)和一个\(k \times n\)的矩阵\(B\),其中\(4 \leq N \leq 1000, \, 2 \leq K \leq 6\). 矩阵\(C=A \cdot B\),求矩阵\(C^{N^2}\)的各个元素之和,以上矩阵运算均是在模\(6\)的情况下计算的. 分析: 如果我们直接计算\(A \cdot B\)的话,这个矩阵非常大,不可能进行快速幂计算. 所以要变形一下, \((A \cdot B)^{N^2}=A \cdot…
题目 给定矩阵A, B和模数p,求最小的正整数x满足 A^x = B(mod p). 分析 与整数的离散对数类似,只不过普通乘法换乘了矩阵乘法. 由于矩阵的求逆麻烦,使用 $A^{km-t} = B(mod \ p)$ 形式的BSGS. 然后就是判断矩阵是否相等, 一种方法是对矩阵进行Hash, 这里为了防止两个不同矩阵的Hash值冲突,使用了两个底数进行Hash. #include<bits/stdc++.h> using namespace std; typedef long long l…
题目大意:给一个n阶方阵,求A1+A2+A3+......Ak. 题目分析:令F(k)=A1+A2+A3+......Ak.当k为偶数时,F(k)=F(k/2)*(E+Ak/2),k为奇数时,F(k)=F(k/2)*(E+Ak/2)+Ak.证明这两条公式也很简单,把这两条公式展开就行了.根据公式,递归即可. 代码如下: # include<iostream> # include<cstdio> # include<cstring> # include<algori…
One day, Alice and Bob felt bored again, Bob knows Alice is a girl who loves math and is just learning something about matrix, so he decided to make a crazy problem for her. Bob has a six-faced dice which has numbers 0, 1, 2, 3, 4 and 5 on each face.…
首先我们来想一下计算A+A^2+A^3...+A^k. 如果A=2,k=6.那你怎么算 2+22+23+24+25+26 = ?= (2+22+23)*(1+23) 如果A=2,k=7.那你怎么算 2+22+23+24+25+26+27 = ?= (2+22+23)*(1+23)+27 so....同理: 当k是偶数,A+A^2+A^3...+A^k=(E+A^(k/2))*(A+A^2...+A^(k/2)). 当k是奇数,A+A^2+A^3...+A^k=(E+A^(k/2))*(A+A^2…
求A+A^1+...+A^n 转换一下变成|A  E|,的n+1次方就是|A^(n+1)  A^n+...+A+E| |0  E|                       |    0             E              | 最后结果减去E就行了,还有一点就是-1之后可能会变成负数,所以要+10再%10 #include<map> #include<set> #include<cmath> #include<queue> #includ…