Fork me on GitHub

矩阵快速幂

以下资料室是学习矩阵快速幂 够用了 一些矩阵的选择可以自己算一下
普通快速幂的教程:https://v.qq.com/x/page/l0323gb50p2.html
模板

public class Main {
	public static int quick_pow(int a,int b,int mod) {
		int ans = 1;
		int temp = a;
		while(b>0) {
			if(b%2==1) {
				ans *= temp%mod;
			}
			temp *= temp;
			//System.out.println(ans+" "+temp);
			temp %= mod;
			b = b>>1;
			
		}
		return ans;
	}
	public static void main(String[] args) {
	System.out.println(quick_pow(2,10, 1000000));
	}
}
二进制1010
2^3+0*2^2+2^1+0*2^0 ->->->2^3(也就是八 后面要成了2的幂) 要除于删除才能把整个消掉(1/2=0)
2^10 = 1 * 2^2 * 2^8

矩阵快速幂的教程:https://v.qq.com/x/page/i03233ew1gm.html
参考:https://blog.csdn.net/wust_zzwh/article/details/52058209 通过公式验证矩阵快速幂 矩阵的系数
妈咪说MommyTalk 费马小定理
参考文献:https://blog.csdn.net/QuinnNorris/article/details/7758709
https://www.cnblogs.com/zquzjx/p/10549775.html
https://www.cnblogs.com/Howe-Young/p/4097277.html(因为数比较大 题目会跟你说模的问题)
推荐阅读https://www.matrix67.com/blog/archives/276
https://blog.csdn.net/u012061345/article/details/52224623
https://www.bilibili.com/video/av8570006?from=search&seid=3244138400881626958

posted @ 2019-07-08 10:54  cznczai  阅读(154)  评论(0编辑  收藏  举报