比赛 不准粘代码,必须自己写(HS除外) 评测结果 AAAAAAAAAA
题目名称 中国象棋 最终得分 100
用户昵称 leon 运行时间 0.194 s
代码语言 C++ 内存使用 22.50 MiB
提交时间 2019-09-25 18:50:31
显示代码纯文本
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. const int maxn=105;
  4. const int mod=9999973;
  5. long int f[maxn][maxn][maxn];
  6. int C(int x){
  7. return ((x*(x-1))/2)%mod;
  8. }
  9. int main(){
  10. freopen("cchess.in","r",stdin);
  11. freopen("cchess.out","w",stdout);
  12. int m,n;
  13. cin>>n>>m;//m_hang
  14. f[0][0][0]=1;
  15. for(int i=1;i<=n;i++)
  16. for(int j=0;j<=m;j++)
  17. for(int k=0;k<=m-j;k++){
  18. f[i][j][k]=f[i-1][j][k];
  19. if(k>=1)
  20. f[i][j][k]+=f[i-1][j+1][k-1]*(j+1);
  21. if(j>=1)
  22. f[i][j][k]+=f[i-1][j-1][k]*(m-j+1-k);
  23. if(k>=2)
  24. f[i][j][k]+=f[i-1][j+2][k-2]*C(j+2);
  25. if(k>=1)
  26. f[i][j][k]+=f[i-1][j][k-1]*j*(m-j-k+1);
  27. if(j>=2)
  28. f[i][j][k]+=f[i-1][j-2][k]*C(m-j-k+2);
  29. f[i][j][k]%=mod;
  30. }
  31. long long ans=0;
  32. for(int i=0;i<=m;i++)
  33. for(int j=0;j<=m;j++){
  34. ans+=f[n][i][j];
  35. ans%=mod;
  36. }
  37. cout<<ans;
  38. return 0;
  39. }
  40.