矩阵的幂
求斐波那契第n项的值.0<n<10^16
#include"stdio.h"
#define mod 10000005
struct Point
{
long long a[2][2];
Point()
{
for(int i=0;i<2;i++)
for(int j=0;j<2;j++)
a[i][j]=0;
}
};
Point operator *(Point &x,Point &y)
{
Point rst;
for(int i=0;i<2;i++)
for(int j=0;j<2;j++)
{
for(int k=0;k<2;k++)
rst.a[i][j]+=(x.a[k][j]*y.a[i][k])%mod;
}
return rst;
}
int main()
{
Point x,rst;
int t;
while(~scanf("%d",&t))
{
x.a[0][0]=x.a[1][0]=x.a[0][1]=1;x.a[1][1]=0;
rst=x;
t--;
while(t>0)
{
if(t&1) rst=rst*x;
x=x*x;
t>>=1;
}
printf("%lld\n",rst.a[1][0]%mod);
}
return 0;
}