1 条题解

  • 0
    @ 2025-10-8 16:52:36
    #include<bits/stdc++.h>
    using namespace std;
    typedef long long LL;
    const LL P=7777777;
    struct node
    {
    	LL a[11][11];
    	node(){memset(a,0,sizeof a);}
    };
    int n,N;LL f[11];
    
    node operator*(node A, node B)
    {
    	node C;
    	for(int i=1;i<=n;i++)
    		for(int j =1;j<=n;j++)
    			for(int k=1; k<=n;k++)
    				C.a[i][j]=(C.a[i][j]+A.a[i][k]*B.a[k][j])%P;
    	return C;
    }
    node qpow(node A, int b)
    {
    	node C;for(int i=1;i<=n;i++)C.a[i][i]=1;
    	for(;b;b>>=1)
    	{
    		if(b&1)C=C*A; 
    		A=A*A;
    	}
    	return C;
    }
    int main()
    {
        scanf("%d%d",&n,&N);  
        memset(f,0,sizeof(f));f[0]=1;    
        for(int i=1;i<=n;i++)
            for(int j=1;j<=i;j++)
                f[i]+=f[i-j];       
        node A;
    	for(int i=1;i<=n;i++)A.a[1][i]=f[i-1];
        node ff;
        for(int i=2;i<=n;i++)ff.a[i][i-1]=1;
        for(int i=1;i<=n;i++)ff.a[i][n]=1;
        A=A*qpow(ff,N);
        printf("%lld\n",A.a[1][1]);
        return 0;
    }
    
    • 1

    信息

    ID
    600
    时间
    1000ms
    内存
    128MiB
    难度
    6
    标签
    递交数
    110
    已通过
    38
    上传者