再次,,,,,虚(一开始看错题了,看成一次移动一个棋子,能移动1-d个格子。。。这样的话有没有大神会做??本蒟蒻就教)
额,,直接%%%%把。。。http://hzwer.com/5760.html
1 #include<cstdio> 2 #include<iostream> 3 #include<algorithm> 4 #include<map> 5 #include<queue> 6 #define N 1000005 7 #define inf 1000000000 8 #define LL long long 9 using namespace std; 10 const LL mod=1e9+7; 11 LL tot,ans; 12 int n,K,d,p; 13 LL bin[25]; 14 LL c[10005][205],f[25][10005]; 15 void pre() 16 { 17 for (int i=0; i<=n; i++) c[i][0]=1; 18 for (int i=1; i<=n; i++) 19 for (int j=1; j<=min(2*K,i); j++) 20 c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod; 21 } 22 int C(int x, int y) 23 { 24 if (y>x-y) y=x-y; 25 return c[x][y]; 26 } 27 void add(LL &x, LL y) 28 { 29 x=(x+y)%mod; 30 } 31 int main() 32 { 33 bin[0]=1; for (int i=1; i<=15; i++) bin[i]=bin[i-1]<<1; 34 scanf("%d %d %d",&n,&K,&d); K/=2; pre(); f[0][0]=1; 35 for (int i=0; i<15; i++) 36 for (int j=0; j<=n-2*K; j++) 37 for (int k=0; k*(d+1)<=K && j+(d+1)*k*bin[i]<=n-2*K; k++) 38 { 39 add(f[i+1][j+k*(d+1)*bin[i]],f[i][j]*C(K,k*(d+1))); 40 } 41 for (int i=0; i<=n-2*K; i++) 42 add(ans,f[15][i]*C(n-i-K,K)); 43 tot=C(n,K*2); 44 cout<<(tot+mod-ans)%mod; 45 return 0; 46 }