题意很明确
就是用给的规律进行矩阵快速幂取模
#include
using namespace std;
#include
#include
#include
const int MAXN=3;
int n;
int mod;
class Matrix{
public:
int n;//行
int m;//列
int a[MAXN][MAXN];
void clear(){
n=m=0;
memset(a,0,sizeof(a));
}
Matrix operator +(const Matrix &b)const{
Matrix tmp;
tmp.n=n;
tmp.m=m;
for(int i=0;i
>=1; } return ret.a[1][1]; } int main() { mod=10000; while(scanf("%d",&n),n!=-1){ printf("%d\n",quickPow_Matrix(n)); } return 0; }