标签:
Description
Input
Output
Sample Input
Sample Output
描述
输入
输出
样例输入
样例输出
#include<cstdio>
#include<cstring>
using namespace std;
long long a[20],m,n,b[20];
void f()
{
long long s1[14][14],s2[14][14],s3[14][14],sum=0;
long long i,j,k;
for (i=0;i<=9;i++)
for (j=0;j<=9;j++)
{
if (j==9)
{
s1[i][9]=a[9-i];
s2[i][9]=a[9-i];
}
else if (i==j+1)
{
s1[i][j]=1;
s2[i][j]=1;
}
else
{
s1[i][j]=0;
s2[i][j]=0;
}
}
m-=10;
while (m)
{
if (m&1)
{
memset(s3,0,sizeof(s3));
for (i=0;i<=9;i++)
for (j=0;j<=9;j++)
for (k=0;k<=9;k++)
s3[i][j]+=(s1[i][k]*s2[k][j])%n;
for (i=0;i<=9;i++)
for (j=0;j<=9;j++)
s2[i][j]=s3[i][j];
}
memset(s3,0,sizeof(s3));
for (i=0;i<=9;i++)
for (j=0;j<=9;j++)
for (k=0;k<=9;k++)
s3[i][j]+=(s1[i