标签:一个 size void http getch href new for fas
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define N 32
#define getchar nc
using namespace std;
inline char nc(){
static char buf[100000],*p1=buf,*p2=buf;
return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline ll read()
{
register ll x=0,f=1;register char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
return x*f;
}
inline void write(register int x)
{
if(!x)putchar('0');if(x<0)x=-x,putchar('-');
static int sta[20];register int tot=0;
while(x)sta[tot++]=x%10,x/=10;
while(tot)putchar(sta[--tot]+48);
}
struct mat{
int a[N][N];
inline mat()
{
memset(a,0,sizeof(a));
}
inline mat operator*(const mat&b)const{
mat c;
for(register int i=0;i<N;++i)
for(register int j=0;j<N;++j)
for(register int k=0;k<N;++k)
c.a[i][j]=(c.a[i][j]+1ll*a[i][k]*b.a[k][j])%mod;
return c;
}
}s;
inline mat fastpow(register mat a,register ll b)
{
mat res;
for(register int i=0;i<N;++i)
res.a[i][i]=1;
while(b)
{
if(b&1)
res=res*a;
a=a*a;
b>>=1;
}
return res;
}
ll n,ans;
int m,k,lim,ok[N];
inline void work(register int zt,register int num)
{
ok[zt]=1;
int kl=zt>>1;
s.a[zt][kl]=1;
if(num==k&&!(zt&1))
return;
s.a[zt][kl+(1<<(m-1))]=1;
}
inline void dfs(register int x,register int num,register int zt)
{
if(x==m+1)
{
work(zt,num);
return;
}
dfs(x+1,num,zt);
if(num<k)
dfs(x+1,num+1,zt|(1<<(x-1)));
}
int main()
{
n=read(),m=read(),k=read();
dfs(1,0,0);
s=fastpow(s,n);
for(register int i=0;i<(1<<m);++i)
if(ok[i])
ans=(ans+s.a[i][i])%mod;
write(ans);
return 0;
}
标签:一个 size void http getch href new for fas
原文地址:https://www.cnblogs.com/yzhang-rp-inf/p/10915018.html