快速幂的思想:二分
参考文献:http://blog.csdn.net/shiwei408/article/details/8818386
http://blog.csdn.net/hkdgjqr/article/details/5381292
hdu 2817(整数快速幂) A sequence of numbers
解题思路:
分别写出等差、等比数列通项an的表达式:
快速幂取模+基本的模运算就做了,附代码:
#include
#include
#include
#include
poj 3233(矩阵快速幂+二分)Matrix Power Series
题目链接:http://poj.org/problem?id=3233
解题思路:由于k比较大,如果每一项快速幂在相加,肯定会超时,需要二份求解,参考代码:
#include
#include
#include
#include