![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
快速幂/矩阵快速幂
紫杉丶
这个作者很懒,什么都没留下…
展开
-
快速求幂算法
快速求正整数次幂,当然不能直接死乘。举个例子:3 ^ 999 = 3 * 3 * 3 * … * 3直接乘要做998次乘法。但事实上可以这样做,先求出2^k次幂:3 ^ 2 = 3 * 33 ^ 4 = (3 ^ 2) * (3 ^ 2)3 ^ 8 = (3 ^ 4) * (3 ^ 4)3 ^ 16 = (3 ^ 8) * (3 ^ 8)3 ^ 32 = (3 ^ 16转载 2015-02-05 20:57:54 · 526 阅读 · 0 评论 -
HDU 5171 GTY's birthday gift (矩阵快速幂)
GTY's birthday giftTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 408 Accepted Submission(s): 154Problem DescriptionFFZ's birt原创 2015-02-09 09:25:43 · 1109 阅读 · 0 评论 -
矩阵快速幂模板
#define Matr 10 //矩阵大小,注意能小就小struct mat//矩阵结构体,a表示内容,size大小 矩阵从1开始{ ll a[Matr][Matr],size; mat() { size=0; memset(a,0,sizeof(a)); }};void print(mat m)//原创 2015-02-09 09:15:21 · 502 阅读 · 0 评论 -
HDU 1575 Tr A (矩阵快速幂入门)
题意就不多说了,一道基础的矩阵入门。#include "stack"#include "cstdio"#include "iostream"#include "cmath"#include "set"#include "sstream"#include "cctype"#include "string"#include "cstring"#include "原创 2015-03-08 09:16:04 · 348 阅读 · 0 评论 -
HDU 1757 A Simple Math Problem (矩阵快速幂)
/*构造矩阵If x If x >= 10 f(x) = a0 * f(x-1) + a1 * f(x-2) + a2 * f(x-3) + …… + a9 * f(x-10);|f(10) | |a0 a1 a2 ...a8 a9| |f(9)|| f(9) | | 1 0 0 ... 0 0| |f(8)|| .....| = |.. ... ... ... ..| |原创 2015-03-10 19:07:27 · 297 阅读 · 0 评论