[vijos1067]Warcraft III 守望者的烦恼

就是上次考得fyfy。竟然是原题。。。


// It is made by XZZ
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define rep(a,b,c) for(rg int a=b;a<=c;a++)
#define drep(a,b,c) for(rg int a=b;a>=c;a--)
#define erep(a,b) for(rg int a=fir[b];a;a=nxt[a])
#define il inline
#define rg register
#define vd void
typedef long long ll;
il ll gi(){
    rg ll x=0,f=1;rg char ch=getchar();
    while(ch<'0'||ch>'9')f=ch=='-'?-1:f,ch=getchar();
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
ll k,n;
struct Mat{
    ll s[12][12];
    Mat(){memset(s,0,sizeof s);}
};
const int mod=7777777;
Mat operator *(Mat a,Mat b){
    Mat c;
    rep(i,1,k)rep(j,1,k)rep(l,1,k)
        c.s[i][l]+=a.s[i][j]*b.s[j][l],c.s[i][l]%=mod;
    return c;
}
vd operator *=(Mat&a,Mat b){a=a*b;}
int main(){
    k=gi(),n=gi();
    Mat a,b;
    a.s[1][k]=1;
    rep(i,2,k)b.s[i][i-1]=1;
    rep(i,1,k)b.s[i][k]=1;
    while(n){
	    if(n&1)a*=b;
	    b*=b,n>>=1;
    }printf("%lld\n",a.s[1][k]);
    return 0;
}
posted @ 2017-08-16 12:56  菜狗xzz  阅读(248)  评论(0编辑  收藏  举报